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

Unified Diff: mojom/mojom_parser/mojom/types_test.go

Issue 1805743003: Mojom frontend: Compute, validate and populate struct field version info (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rename ComputeDataForGenerators to ComputeFinalData Created 4 years, 9 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/mojom_parser/mojom/types.go ('k') | mojom/mojom_parser/mojom/user_defined_types.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/mojom_parser/mojom/types_test.go
diff --git a/mojom/mojom_parser/mojom/types_test.go b/mojom/mojom_parser/mojom/types_test.go
index 627edea1c09d2abf833b2a2b421ae146d53adffa..86748d2b8874263529cebf50c37d2d6d250b1949 100644
--- a/mojom/mojom_parser/mojom/types_test.go
+++ b/mojom/mojom_parser/mojom/types_test.go
@@ -352,3 +352,26 @@ func TestValidateAfterResolution(t *testing.T) {
}
}
}
+
+func TestUint32Value(t *testing.T) {
+ cases := []struct {
+ literalValue LiteralValue
+ expectedValue uint32
+ expectedSuccess bool
+ }{
+ {MakeUint32LiteralValue(12345, nil), 12345, true},
+ {MakeInt64LiteralValue(12345, nil), 12345, true},
+ {MakeInt64LiteralValue(1234567890123456, nil), 1015724736, false},
+ {MakeInt32LiteralValue(-12345, nil), 4294954951, false},
+ {MakeFloatLiteralValue(1234.5, nil), 0, false},
+ {MakeStringLiteralValue("12345", nil), 0, false},
+ {MakeBoolLiteralValue(false, nil), 0, false},
+ }
+ for _, c := range cases {
+ got, ok := uint32Value(c.literalValue)
+ if ok != c.expectedSuccess || got != c.expectedValue {
+ t.Errorf("uint32Value(%v) == %v, %v, want %v, %v", c.literalValue,
+ got, ok, c.expectedValue, c.expectedSuccess)
+ }
+ }
+}
« no previous file with comments | « mojom/mojom_parser/mojom/types.go ('k') | mojom/mojom_parser/mojom/user_defined_types.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698