OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package tests | 5 package tests |
6 | 6 |
7 import ( | 7 import ( |
| 8 test_enums_no_type_info "mojo/go/tests/test_enums" |
8 "mojo/public/interfaces/bindings/tests/test_enums" | 9 "mojo/public/interfaces/bindings/tests/test_enums" |
9 "testing" | 10 "testing" |
10 ) | 11 ) |
11 | 12 |
| 13 // TestEnums just exercises the generated go code for enums. It tests that |
| 14 // the generated enum value constants are of the correct type. The difference |
| 15 // between test_enums and test_enums_no_type_info is that the former has been ge
nerated |
| 16 // using 'generate_type_info = true' and the latter has not. Our only goal |
| 17 // in including both is to minimally exercise both generation pathways. |
12 func TestEnums(t *testing.T) { | 18 func TestEnums(t *testing.T) { |
13 if test_enums.TestEnum_Foo != IdentityEnum1(test_enums.TestEnum_Foo) { | 19 if test_enums.TestEnum_Foo != IdentityEnum1(test_enums.TestEnum_Foo) { |
14 t.Errorf("IdentityEnum1 failure.") | 20 t.Errorf("IdentityEnum1 failure.") |
15 } | 21 } |
16 | 22 |
17 if test_enums.TestEnum2_Foo != IdentityEnum2(test_enums.TestEnum2_Foo) { | 23 if test_enums.TestEnum2_Foo != IdentityEnum2(test_enums.TestEnum2_Foo) { |
18 t.Errorf("IdentityEnum1 failure.") | 24 t.Errorf("IdentityEnum1 failure.") |
19 } | 25 } |
| 26 |
| 27 if test_enums_no_type_info.TestEnum_Foo != IdentityEnumB1(test_enums_no_
type_info.TestEnum_Foo) { |
| 28 t.Errorf("IdentityEnum1 failure.") |
| 29 } |
| 30 |
| 31 if test_enums_no_type_info.TestEnum2_Foo != IdentityEnumB2(test_enums_no
_type_info.TestEnum2_Foo) { |
| 32 t.Errorf("IdentityEnum1 failure.") |
| 33 } |
20 } | 34 } |
21 | 35 |
22 func IdentityEnum1(x test_enums.TestEnum) test_enums.TestEnum { | 36 func IdentityEnum1(x test_enums.TestEnum) test_enums.TestEnum { |
23 return x | 37 return x |
24 } | 38 } |
25 | 39 |
26 func IdentityEnum2(x test_enums.TestEnum2) test_enums.TestEnum2 { | 40 func IdentityEnum2(x test_enums.TestEnum2) test_enums.TestEnum2 { |
27 return x | 41 return x |
28 } | 42 } |
| 43 |
| 44 func IdentityEnumB1(x test_enums_no_type_info.TestEnum) test_enums_no_type_info.
TestEnum { |
| 45 return x |
| 46 } |
| 47 |
| 48 func IdentityEnumB2(x test_enums_no_type_info.TestEnum2) test_enums_no_type_info
.TestEnum2 { |
| 49 return x |
| 50 } |
OLD | NEW |