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

Side by Side Diff: mojom/generators/go/templates/structs_test.go

Issue 2045063002: [New go generator] Implement declaring unions. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 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 | « mojom/generators/go/templates/structs.go ('k') | mojom/generators/go/templates/templates.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 templates
6
7 import (
8 "testing"
9
10 "mojom/generators/go/translator"
11 )
12
13 func TestStructDecl(t *testing.T) {
14 expected := `type Foo struct {
15 Alpha string
16 Beta uint32
17 }`
18
19 s := translator.StructTemplate{
20 Name: "Foo",
21 Fields: []translator.StructFieldTemplate{
22 {Name: "Alpha", Type: "string"},
23 {Name: "Beta", Type: "uint32"},
24 },
25 }
26
27 check(t, expected, "StructDecl", s)
28 }
29
30 func TestDecodingStructVersions(t *testing.T) {
31 expected := `var someStruct_Versions []bindings.DataHeader = []bindings. DataHeader{
32 bindings.DataHeader{80, 0},
33 bindings.DataHeader{100, 1},
34 bindings.DataHeader{120, 2},
35 }`
36
37 type structVersion struct {
38 NumBytes uint32
39 Version uint32
40 }
41
42 s := struct {
43 PrivateName string
44 Versions []structVersion
45 }{
46 PrivateName: "someStruct",
47 Versions: []structVersion{
48 {80, 0},
49 {100, 1},
50 {120, 2},
51 },
52 }
53
54 check(t, expected, "StructVersions", s)
55 }
OLDNEW
« no previous file with comments | « mojom/generators/go/templates/structs.go ('k') | mojom/generators/go/templates/templates.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698