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

Side by Side Diff: Source/core/html/track/vtt/VTTScannerTest.cpp

Issue 139343006: Rework float value/percentage scanning for VTTRegion (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. 2 * Copyright (c) 2013, Opera Software ASA. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 EXPECT_TRUE(scanner.isAtEnd()); 297 EXPECT_TRUE(scanner.isAtEnd());
298 } 298 }
299 299
300 // Tests scanDigits(). 300 // Tests scanDigits().
301 TEST(VTTScanner, ScanDigits) 301 TEST(VTTScanner, ScanDigits)
302 { 302 {
303 TEST_WITH(scanDigits1, "foo 123 bar 45678"); 303 TEST_WITH(scanDigits1, "foo 123 bar 45678");
304 TEST_WITH(scanDigits2, "-654 1000000000000000000"); 304 TEST_WITH(scanDigits2, "-654 1000000000000000000");
305 } 305 }
306 306
307 void scanFloatValue(const String& input)
308 {
309 VTTScanner scanner(input);
310 float value;
311 // "1."
312 EXPECT_TRUE(scanner.scanFloat(value));
313 EXPECT_EQ(value, 1.0f);
314 EXPECT_TRUE(scanner.scan(' '));
315
316 // "1.0"
317 EXPECT_TRUE(scanner.scanFloat(value));
318 EXPECT_EQ(value, 1.0f);
319 EXPECT_TRUE(scanner.scan(' '));
320
321 // ".0"
322 EXPECT_TRUE(scanner.scanFloat(value));
323 EXPECT_EQ(value, 0.0f);
324 EXPECT_TRUE(scanner.scan(' '));
325
326 // "." (invalid)
327 EXPECT_FALSE(scanner.scanFloat(value));
328 EXPECT_TRUE(scanner.match('.'));
329 EXPECT_TRUE(scanner.scan('.'));
330 EXPECT_TRUE(scanner.scan(' '));
331
332 // "1.0000"
333 EXPECT_TRUE(scanner.scanFloat(value));
334 EXPECT_EQ(value, 1.0f);
335 EXPECT_TRUE(scanner.scan(' '));
336
337 // "01.000"
338 EXPECT_TRUE(scanner.scanFloat(value));
339 EXPECT_EQ(value, 1.0f);
340
341 EXPECT_TRUE(scanner.isAtEnd());
342 }
343
344 // Tests scanFloat().
345 TEST(VTTScanner, ScanFloat)
346 {
347 TEST_WITH(scanFloatValue, "1. 1.0 .0 . 1.0000 01.000");
348 }
349
307 #undef TEST_WITH 350 #undef TEST_WITH
308 351
309 } // namespace 352 } // namespace
OLDNEW
« Source/core/html/track/vtt/VTTScanner.cpp ('K') | « Source/core/html/track/vtt/VTTScanner.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698