Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: mojo/go/tests/enums_test.go

Issue 1945103002: Go bindings: Don't import 'fmt' unless it is needed. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/go/BUILD.gn ('k') | mojo/go/tests/test_enums.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 }
OLDNEW
« no previous file with comments | « mojo/go/BUILD.gn ('k') | mojo/go/tests/test_enums.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698