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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: mojom/generators/go/translator/values_test.go
diff --git a/mojom/generators/go/translator/values_test.go b/mojom/generators/go/translator/values_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..8ddd13b527af6cc7679ea2f7e7a0c32197e35423
--- /dev/null
+++ b/mojom/generators/go/translator/values_test.go
@@ -0,0 +1,43 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package translator
+
+import (
+ "testing"
+
+ //"mojom/generated/mojom_files"
+ "mojom/generated/mojom_types"
+)
+
+func TestTranslateLiteralValue(t *testing.T) {
+ testCases := []struct {
+ expected string
+ literalValue mojom_types.LiteralValue
+ }{
+ {"true", &mojom_types.LiteralValueBoolValue{true}},
+ {"false", &mojom_types.LiteralValueBoolValue{false}},
+ {"32.1", &mojom_types.LiteralValueFloatValue{float32(32.1)}},
+ {"64.2", &mojom_types.LiteralValueDoubleValue{float64(64.2)}},
+ {"8", &mojom_types.LiteralValueUint8Value{uint8(8)}},
+ {"16", &mojom_types.LiteralValueUint16Value{uint16(16)}},
+ {"32", &mojom_types.LiteralValueUint32Value{uint32(32)}},
+ {"64", &mojom_types.LiteralValueUint64Value{uint64(64)}},
+ {"8", &mojom_types.LiteralValueInt8Value{int8(8)}},
+ {"16", &mojom_types.LiteralValueInt16Value{int16(16)}},
+ {"32", &mojom_types.LiteralValueInt32Value{int32(32)}},
+ {"64", &mojom_types.LiteralValueInt64Value{int64(64)}},
+ {"-8", &mojom_types.LiteralValueInt8Value{int8(-8)}},
+ {"-16", &mojom_types.LiteralValueInt16Value{int16(-16)}},
+ {"-32", &mojom_types.LiteralValueInt32Value{int32(-32)}},
+ {"-64", &mojom_types.LiteralValueInt64Value{int64(-64)}},
+ {"\"hello world\"", &mojom_types.LiteralValueStringValue{"hello world"}},
+ }
+
+ translator := NewTranslator(nil)
+ for _, testCase := range testCases {
+ value := mojom_types.ValueLiteralValue{testCase.literalValue}
+ checkEq(t, testCase.expected, translator.translateValue(&value))
+ }
+}
« 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