OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package serialization | 5 package serialization |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "compress/gzip" | 9 "compress/gzip" |
10 "encoding/base64" | 10 "encoding/base64" |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 } | 1148 } |
1149 } | 1149 } |
1150 } | 1150 } |
1151 | 1151 |
1152 // TestWithComputedData is similar to the previous test except that it sets | 1152 // TestWithComputedData is similar to the previous test except that it sets |
1153 // emitComputedPackingData = true. | 1153 // emitComputedPackingData = true. |
1154 func TestWithComputedData(t *testing.T) { | 1154 func TestWithComputedData(t *testing.T) { |
1155 test := singleFileTest{} | 1155 test := singleFileTest{} |
1156 | 1156 |
1157 //////////////////////////////////////////////////////////// | 1157 //////////////////////////////////////////////////////////// |
| 1158 // Test Case: Empty struct |
| 1159 //////////////////////////////////////////////////////////// |
| 1160 { |
| 1161 contents := ` |
| 1162 struct Foo{ |
| 1163 };` |
| 1164 |
| 1165 test.addTestCase("", contents) |
| 1166 |
| 1167 test.expectedFile().DeclaredMojomObjects.Structs = &[]string{"TY
PE_KEY:Foo"} |
| 1168 |
| 1169 test.expectedGraph().ResolvedTypes["TYPE_KEY:Foo"] = &mojom_type
s.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
| 1170 DeclData: test.newDeclData("Foo", "Foo"), |
| 1171 Fields: []mojom_types.StructField{}, |
| 1172 VersionInfo: &[]mojom_types.StructVersion{ |
| 1173 mojom_types.StructVersion{ |
| 1174 VersionNumber: 0, |
| 1175 NumFields: 0, |
| 1176 NumBytes: 8, |
| 1177 }, |
| 1178 }, |
| 1179 }} |
| 1180 |
| 1181 test.endTestCase() |
| 1182 } |
| 1183 |
| 1184 //////////////////////////////////////////////////////////// |
1158 // Test Case: Test struct field min versions: 1,2 | 1185 // Test Case: Test struct field min versions: 1,2 |
1159 //////////////////////////////////////////////////////////// | 1186 //////////////////////////////////////////////////////////// |
1160 { | 1187 { |
1161 contents := ` | 1188 contents := ` |
1162 struct Foo{ | 1189 struct Foo{ |
1163 int32 x; | 1190 int32 x; |
1164 int32 y; | 1191 int32 y; |
1165 | 1192 |
1166 [MinVersion = 1] | 1193 [MinVersion = 1] |
1167 array<int32>? z; | 1194 array<int32>? z; |
(...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3185 } | 3212 } |
3186 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na
ctual=\n*****\n%q\n*****\n"+ | 3213 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na
ctual=\n*****\n%q\n*****\n"+ |
3187 "match failed at position %d: expected=\n*****\n
%q\n******\nactual=\n*****\n%q\n******\n", | 3214 "match failed at position %d: expected=\n*****\n
%q\n******\nactual=\n*****\n%q\n******\n", |
3188 expectedString, actualString, diffPos, mismatchE
xpected, mismatchActual) | 3215 expectedString, actualString, diffPos, mismatchE
xpected, mismatchActual) |
3189 } else { | 3216 } else { |
3190 return fmt.Errorf("expected != actual but the two printe
d equal.") | 3217 return fmt.Errorf("expected != actual but the two printe
d equal.") |
3191 } | 3218 } |
3192 } | 3219 } |
3193 return nil | 3220 return nil |
3194 } | 3221 } |
OLD | NEW |