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

Unified Diff: mojom/generators/go/templates/declarations_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojom/generators/go/templates/declarations.go ('k') | mojom/generators/go/templates/decoding.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/generators/go/templates/declarations_test.go
diff --git a/mojom/generators/go/templates/declarations_test.go b/mojom/generators/go/templates/declarations_test.go
deleted file mode 100644
index 5b4b3329a6096069dcb38968d0a8a7cfd9463828..0000000000000000000000000000000000000000
--- a/mojom/generators/go/templates/declarations_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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 templates
-
-import (
- "bytes"
- "fmt"
- "strings"
- "testing"
-
- "mojom/generators/go/gofmt"
- "mojom/generators/go/translator"
-)
-
-func check(t *testing.T, expected string, template string, input interface{}) {
- buffer := &bytes.Buffer{}
- if err := goFileTmpl.ExecuteTemplate(buffer, template, input); err != nil {
- panic(err)
- }
-
- src := buffer.String()
- actual, err := gofmt.FormatFragment(src)
- if err != nil {
- t.Fatalf("Formatting failed: %s\n%s\n", err, src)
- }
-
- if expected != actual {
- errorMsg := fmt.Sprintf("Failed check: Expected\n%s\nActual\n%s\n", expected, actual)
- if strings.TrimSpace(expected) == strings.TrimSpace(actual) {
- errorMsg = fmt.Sprintf("%s\nTrailing or leading spaces differ.\n", errorMsg)
- }
- t.Fatalf(errorMsg)
- }
-}
-
-func TestStructDecl(t *testing.T) {
- expected := `type Foo struct {
- Alpha string
- Beta uint32
-}`
-
- s := translator.StructTemplate{
- Name: "Foo",
- Fields: []translator.StructFieldTemplate{
- {Name: "Alpha", Type: "string"},
- {Name: "Beta", Type: "uint32"},
- },
- }
-
- check(t, expected, "StructDecl", s)
-}
« no previous file with comments | « mojom/generators/go/templates/declarations.go ('k') | mojom/generators/go/templates/decoding.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698