OLD | NEW |
(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 } |
OLD | NEW |