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

Side by Side Diff: mojom/generators/go/translator/values_test.go

Issue 2233963003: Add support for constants in the new go generator. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge branch 'master' of github.com:domokit/mojo into const Created 4 years, 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package translator
6
7 import (
8 "testing"
9
10 //"mojom/generated/mojom_files"
11 "mojom/generated/mojom_types"
12 )
13
14 func TestTranslateLiteralValue(t *testing.T) {
15 testCases := []struct {
16 expected string
17 literalValue mojom_types.LiteralValue
18 }{
19 {"true", &mojom_types.LiteralValueBoolValue{true}},
20 {"false", &mojom_types.LiteralValueBoolValue{false}},
21 {"32.1", &mojom_types.LiteralValueFloatValue{float32(32.1)}},
22 {"64.2", &mojom_types.LiteralValueDoubleValue{float64(64.2)}},
23 {"8", &mojom_types.LiteralValueUint8Value{uint8(8)}},
24 {"16", &mojom_types.LiteralValueUint16Value{uint16(16)}},
25 {"32", &mojom_types.LiteralValueUint32Value{uint32(32)}},
26 {"64", &mojom_types.LiteralValueUint64Value{uint64(64)}},
27 {"8", &mojom_types.LiteralValueInt8Value{int8(8)}},
28 {"16", &mojom_types.LiteralValueInt16Value{int16(16)}},
29 {"32", &mojom_types.LiteralValueInt32Value{int32(32)}},
30 {"64", &mojom_types.LiteralValueInt64Value{int64(64)}},
31 {"-8", &mojom_types.LiteralValueInt8Value{int8(-8)}},
32 {"-16", &mojom_types.LiteralValueInt16Value{int16(-16)}},
33 {"-32", &mojom_types.LiteralValueInt32Value{int32(-32)}},
34 {"-64", &mojom_types.LiteralValueInt64Value{int64(-64)}},
35 {"\"hello world\"", &mojom_types.LiteralValueStringValue{"hello world"}},
36 }
37
38 translator := NewTranslator(nil)
39 for _, testCase := range testCases {
40 value := mojom_types.ValueLiteralValue{testCase.literalValue}
41 checkEq(t, testCase.expected, translator.translateValue(&value))
42 }
43 }
OLDNEW
« mojom/generators/go/translator/mojom_file.go ('K') | « mojom/generators/go/translator/values.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698