1
2
3
4
5 package fips140_test
6
7 import (
8 "crypto/internal/fips140"
9 "slices"
10 "testing"
11 )
12
13
14
15
16
17
18
19
20 func wantLiterals() (a []fips140.TestType, b []fips140.TestType2) {
21 a = append(a, fips140.TestType{
22 A: "a",
23 B: "",
24 C: "",
25 })
26 a = append(a, fips140.TestType{
27 A: "a",
28 B: fips140.DynamicString(),
29 C: "",
30 })
31 b = append(b, fips140.TestType2{
32 A: "a",
33 B: "",
34 C: "",
35 D: "",
36 E: "",
37 })
38 b = append(b, fips140.TestType2{
39 A: "a",
40 B: fips140.DynamicString(),
41 C: "",
42 D: "d",
43 E: fips140.DynamicString(),
44 })
45 return a, b
46 }
47
48 func TestCompile(t *testing.T) {
49 wantA, wantB := wantLiterals()
50 gotA, gotB := fips140.Literals()
51 if !slices.Equal(gotA, wantA) {
52 t.Errorf("FIPS and non-FIPS mode produce different results: want %q, got %q", wantA, gotA)
53 }
54 if !slices.Equal(gotB, wantB) {
55 t.Errorf("FIPS and non-FIPS mode produce different results: want %q, got %q", wantB, gotB)
56 }
57 }
58
View as plain text