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

Side by Side Diff: chrome/common/json_schema_validator_unittest_base.cc

Issue 6248026: Rename Real* to Double* in values.* and dependent files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More renames Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/common/json_schema_validator_unittest_base.h" 5 #include "chrome/common/json_schema_validator_unittest_base.h"
6 6
7 #include <cfloat> 7 #include <cfloat>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 ExpectValid(TEST_SOURCE, 434 ExpectValid(TEST_SOURCE,
435 scoped_ptr<Value>(Value::CreateIntegerValue(1)).get(), 435 scoped_ptr<Value>(Value::CreateIntegerValue(1)).get(),
436 schema.get(), NULL); 436 schema.get(), NULL);
437 ExpectValid(TEST_SOURCE, 437 ExpectValid(TEST_SOURCE,
438 scoped_ptr<Value>(Value::CreateIntegerValue(50)).get(), 438 scoped_ptr<Value>(Value::CreateIntegerValue(50)).get(),
439 schema.get(), NULL); 439 schema.get(), NULL);
440 ExpectValid(TEST_SOURCE, 440 ExpectValid(TEST_SOURCE,
441 scoped_ptr<Value>(Value::CreateIntegerValue(100)).get(), 441 scoped_ptr<Value>(Value::CreateIntegerValue(100)).get(),
442 schema.get(), NULL); 442 schema.get(), NULL);
443 ExpectValid(TEST_SOURCE, 443 ExpectValid(TEST_SOURCE,
444 scoped_ptr<Value>(Value::CreateRealValue(88.88)).get(), 444 scoped_ptr<Value>(Value::CreateDoubleValue(88.88)).get(),
445 schema.get(), NULL); 445 schema.get(), NULL);
446 446
447 ExpectNotValid( 447 ExpectNotValid(
448 TEST_SOURCE, 448 TEST_SOURCE,
449 scoped_ptr<Value>(Value::CreateRealValue(0.5)).get(), 449 scoped_ptr<Value>(Value::CreateDoubleValue(0.5)).get(),
450 schema.get(), NULL, "", 450 schema.get(), NULL, "",
451 JSONSchemaValidator::FormatErrorMessage( 451 JSONSchemaValidator::FormatErrorMessage(
452 JSONSchemaValidator::kNumberMinimum, "1")); 452 JSONSchemaValidator::kNumberMinimum, "1"));
453 ExpectNotValid( 453 ExpectNotValid(
454 TEST_SOURCE, 454 TEST_SOURCE,
455 scoped_ptr<Value>(Value::CreateRealValue(100.1)).get(), 455 scoped_ptr<Value>(Value::CreateDoubleValue(100.1)).get(),
456 schema.get(), NULL, "", 456 schema.get(), NULL, "",
457 JSONSchemaValidator::FormatErrorMessage( 457 JSONSchemaValidator::FormatErrorMessage(
458 JSONSchemaValidator::kNumberMaximum, "100")); 458 JSONSchemaValidator::kNumberMaximum, "100"));
459 } 459 }
460 460
461 void JSONSchemaValidatorTestBase::TestTypeClassifier() { 461 void JSONSchemaValidatorTestBase::TestTypeClassifier() {
462 EXPECT_EQ("boolean", JSONSchemaValidator::GetJSONSchemaType( 462 EXPECT_EQ("boolean", JSONSchemaValidator::GetJSONSchemaType(
463 scoped_ptr<Value>(Value::CreateBooleanValue(true)).get())); 463 scoped_ptr<Value>(Value::CreateBooleanValue(true)).get()));
464 EXPECT_EQ("boolean", JSONSchemaValidator::GetJSONSchemaType( 464 EXPECT_EQ("boolean", JSONSchemaValidator::GetJSONSchemaType(
465 scoped_ptr<Value>(Value::CreateBooleanValue(false)).get())); 465 scoped_ptr<Value>(Value::CreateBooleanValue(false)).get()));
466 466
467 // It doesn't matter whether the C++ type is 'integer' or 'real'. If the 467 // It doesn't matter whether the C++ type is 'integer' or 'real'. If the
468 // number is integral and within the representable range of integers in 468 // number is integral and within the representable range of integers in
469 // double, it's classified as 'integer'. 469 // double, it's classified as 'integer'.
470 EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType( 470 EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType(
471 scoped_ptr<Value>(Value::CreateIntegerValue(42)).get())); 471 scoped_ptr<Value>(Value::CreateIntegerValue(42)).get()));
472 EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType( 472 EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType(
473 scoped_ptr<Value>(Value::CreateIntegerValue(0)).get())); 473 scoped_ptr<Value>(Value::CreateIntegerValue(0)).get()));
474 EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType( 474 EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType(
475 scoped_ptr<Value>(Value::CreateRealValue(42)).get())); 475 scoped_ptr<Value>(Value::CreateDoubleValue(42)).get()));
476 EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType( 476 EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType(
477 scoped_ptr<Value>( 477 scoped_ptr<Value>(
478 Value::CreateRealValue(pow(2.0, DBL_MANT_DIG))).get())); 478 Value::CreateDoubleValue(pow(2.0, DBL_MANT_DIG))).get()));
479 EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType( 479 EXPECT_EQ("integer", JSONSchemaValidator::GetJSONSchemaType(
480 scoped_ptr<Value>( 480 scoped_ptr<Value>(
481 Value::CreateRealValue(pow(-2.0, DBL_MANT_DIG))).get())); 481 Value::CreateDoubleValue(pow(-2.0, DBL_MANT_DIG))).get()));
482 482
483 // "number" is only used for non-integral numbers, or numbers beyond what 483 // "number" is only used for non-integral numbers, or numbers beyond what
484 // double can accurately represent. 484 // double can accurately represent.
485 EXPECT_EQ("number", JSONSchemaValidator::GetJSONSchemaType( 485 EXPECT_EQ("number", JSONSchemaValidator::GetJSONSchemaType(
486 scoped_ptr<Value>(Value::CreateRealValue(88.8)).get())); 486 scoped_ptr<Value>(Value::CreateDoubleValue(88.8)).get()));
487 EXPECT_EQ("number", JSONSchemaValidator::GetJSONSchemaType( 487 EXPECT_EQ("number", JSONSchemaValidator::GetJSONSchemaType(
488 scoped_ptr<Value>(Value::CreateRealValue( 488 scoped_ptr<Value>(Value::CreateDoubleValue(
489 pow(2.0, DBL_MANT_DIG) * 2)).get())); 489 pow(2.0, DBL_MANT_DIG) * 2)).get()));
490 EXPECT_EQ("number", JSONSchemaValidator::GetJSONSchemaType( 490 EXPECT_EQ("number", JSONSchemaValidator::GetJSONSchemaType(
491 scoped_ptr<Value>(Value::CreateRealValue( 491 scoped_ptr<Value>(Value::CreateDoubleValue(
492 pow(-2.0, DBL_MANT_DIG) * 2)).get())); 492 pow(-2.0, DBL_MANT_DIG) * 2)).get()));
493 493
494 EXPECT_EQ("string", JSONSchemaValidator::GetJSONSchemaType( 494 EXPECT_EQ("string", JSONSchemaValidator::GetJSONSchemaType(
495 scoped_ptr<Value>(Value::CreateStringValue("foo")).get())); 495 scoped_ptr<Value>(Value::CreateStringValue("foo")).get()));
496 EXPECT_EQ("array", JSONSchemaValidator::GetJSONSchemaType( 496 EXPECT_EQ("array", JSONSchemaValidator::GetJSONSchemaType(
497 scoped_ptr<Value>(new ListValue()).get())); 497 scoped_ptr<Value>(new ListValue()).get()));
498 EXPECT_EQ("object", JSONSchemaValidator::GetJSONSchemaType( 498 EXPECT_EQ("object", JSONSchemaValidator::GetJSONSchemaType(
499 scoped_ptr<Value>(new DictionaryValue()).get())); 499 scoped_ptr<Value>(new DictionaryValue()).get()));
500 EXPECT_EQ("null", JSONSchemaValidator::GetJSONSchemaType( 500 EXPECT_EQ("null", JSONSchemaValidator::GetJSONSchemaType(
501 scoped_ptr<Value>(Value::CreateNullValue()).get())); 501 scoped_ptr<Value>(Value::CreateNullValue()).get()));
(...skipping 11 matching lines...) Expand all
513 ExpectValid(TEST_SOURCE, scoped_ptr<Value>(new ListValue()).get(), 513 ExpectValid(TEST_SOURCE, scoped_ptr<Value>(new ListValue()).get(),
514 schema.get(), NULL); 514 schema.get(), NULL);
515 515
516 schema->SetString("type", "string"); 516 schema->SetString("type", "string");
517 ExpectValid(TEST_SOURCE, 517 ExpectValid(TEST_SOURCE,
518 scoped_ptr<Value>(Value::CreateStringValue("foobar")).get(), 518 scoped_ptr<Value>(Value::CreateStringValue("foobar")).get(),
519 schema.get(), NULL); 519 schema.get(), NULL);
520 520
521 schema->SetString("type", "number"); 521 schema->SetString("type", "number");
522 ExpectValid(TEST_SOURCE, 522 ExpectValid(TEST_SOURCE,
523 scoped_ptr<Value>(Value::CreateRealValue(88.8)).get(), 523 scoped_ptr<Value>(Value::CreateDoubleValue(88.8)).get(),
524 schema.get(), NULL); 524 schema.get(), NULL);
525 ExpectValid(TEST_SOURCE, 525 ExpectValid(TEST_SOURCE,
526 scoped_ptr<Value>(Value::CreateRealValue(42)).get(), 526 scoped_ptr<Value>(Value::CreateDoubleValue(42)).get(),
527 schema.get(), NULL); 527 schema.get(), NULL);
528 ExpectValid(TEST_SOURCE, 528 ExpectValid(TEST_SOURCE,
529 scoped_ptr<Value>(Value::CreateIntegerValue(42)).get(), 529 scoped_ptr<Value>(Value::CreateIntegerValue(42)).get(),
530 schema.get(), NULL); 530 schema.get(), NULL);
531 ExpectValid(TEST_SOURCE, 531 ExpectValid(TEST_SOURCE,
532 scoped_ptr<Value>(Value::CreateIntegerValue(0)).get(), 532 scoped_ptr<Value>(Value::CreateIntegerValue(0)).get(),
533 schema.get(), NULL); 533 schema.get(), NULL);
534 534
535 schema->SetString("type", "integer"); 535 schema->SetString("type", "integer");
536 ExpectValid(TEST_SOURCE, 536 ExpectValid(TEST_SOURCE,
537 scoped_ptr<Value>(Value::CreateIntegerValue(42)).get(), 537 scoped_ptr<Value>(Value::CreateIntegerValue(42)).get(),
538 schema.get(), NULL); 538 schema.get(), NULL);
539 ExpectValid(TEST_SOURCE, 539 ExpectValid(TEST_SOURCE,
540 scoped_ptr<Value>(Value::CreateRealValue(42)).get(), 540 scoped_ptr<Value>(Value::CreateDoubleValue(42)).get(),
541 schema.get(), NULL); 541 schema.get(), NULL);
542 ExpectValid(TEST_SOURCE, 542 ExpectValid(TEST_SOURCE,
543 scoped_ptr<Value>(Value::CreateIntegerValue(0)).get(), 543 scoped_ptr<Value>(Value::CreateIntegerValue(0)).get(),
544 schema.get(), NULL); 544 schema.get(), NULL);
545 ExpectValid(TEST_SOURCE, 545 ExpectValid(TEST_SOURCE,
546 scoped_ptr<Value>( 546 scoped_ptr<Value>(
547 Value::CreateRealValue(pow(2.0, DBL_MANT_DIG))).get(), 547 Value::CreateDoubleValue(pow(2.0, DBL_MANT_DIG))).get(),
548 schema.get(), NULL); 548 schema.get(), NULL);
549 ExpectValid(TEST_SOURCE, 549 ExpectValid(TEST_SOURCE,
550 scoped_ptr<Value>( 550 scoped_ptr<Value>(
551 Value::CreateRealValue(pow(-2.0, DBL_MANT_DIG))).get(), 551 Value::CreateDoubleValue(pow(-2.0, DBL_MANT_DIG))).get(),
552 schema.get(), NULL); 552 schema.get(), NULL);
553 553
554 schema->SetString("type", "boolean"); 554 schema->SetString("type", "boolean");
555 ExpectValid(TEST_SOURCE, 555 ExpectValid(TEST_SOURCE,
556 scoped_ptr<Value>(Value::CreateBooleanValue(false)).get(), 556 scoped_ptr<Value>(Value::CreateBooleanValue(false)).get(),
557 schema.get(), NULL); 557 schema.get(), NULL);
558 ExpectValid(TEST_SOURCE, 558 ExpectValid(TEST_SOURCE,
559 scoped_ptr<Value>(Value::CreateBooleanValue(true)).get(), 559 scoped_ptr<Value>(Value::CreateBooleanValue(true)).get(),
560 schema.get(), NULL); 560 schema.get(), NULL);
561 561
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 593
594 schema->SetString("type", "number"); 594 schema->SetString("type", "number");
595 ExpectNotValid(TEST_SOURCE, 595 ExpectNotValid(TEST_SOURCE,
596 scoped_ptr<Value>(Value::CreateStringValue("42")).get(), 596 scoped_ptr<Value>(Value::CreateStringValue("42")).get(),
597 schema.get(), NULL, "", 597 schema.get(), NULL, "",
598 JSONSchemaValidator::FormatErrorMessage( 598 JSONSchemaValidator::FormatErrorMessage(
599 JSONSchemaValidator::kInvalidType, "number", "string")); 599 JSONSchemaValidator::kInvalidType, "number", "string"));
600 600
601 schema->SetString("type", "integer"); 601 schema->SetString("type", "integer");
602 ExpectNotValid(TEST_SOURCE, 602 ExpectNotValid(TEST_SOURCE,
603 scoped_ptr<Value>(Value::CreateRealValue(88.8)).get(), 603 scoped_ptr<Value>(Value::CreateDoubleValue(88.8)).get(),
604 schema.get(), NULL, "", 604 schema.get(), NULL, "",
605 JSONSchemaValidator::FormatErrorMessage( 605 JSONSchemaValidator::FormatErrorMessage(
606 JSONSchemaValidator::kInvalidType, "integer", "number")); 606 JSONSchemaValidator::kInvalidType, "integer", "number"));
607 607
608 schema->SetString("type", "integer"); 608 schema->SetString("type", "integer");
609 ExpectNotValid(TEST_SOURCE, 609 ExpectNotValid(TEST_SOURCE,
610 scoped_ptr<Value>(Value::CreateRealValue(88.8)).get(), 610 scoped_ptr<Value>(Value::CreateDoubleValue(88.8)).get(),
611 schema.get(), NULL, "", 611 schema.get(), NULL, "",
612 JSONSchemaValidator::FormatErrorMessage( 612 JSONSchemaValidator::FormatErrorMessage(
613 JSONSchemaValidator::kInvalidType, "integer", "number")); 613 JSONSchemaValidator::kInvalidType, "integer", "number"));
614 614
615 schema->SetString("type", "boolean"); 615 schema->SetString("type", "boolean");
616 ExpectNotValid(TEST_SOURCE, 616 ExpectNotValid(TEST_SOURCE,
617 scoped_ptr<Value>(Value::CreateIntegerValue(1)).get(), 617 scoped_ptr<Value>(Value::CreateIntegerValue(1)).get(),
618 schema.get(), NULL, "", 618 schema.get(), NULL, "",
619 JSONSchemaValidator::FormatErrorMessage( 619 JSONSchemaValidator::FormatErrorMessage(
620 JSONSchemaValidator::kInvalidType, "boolean", "integer")); 620 JSONSchemaValidator::kInvalidType, "boolean", "integer"));
621 621
622 schema->SetString("type", "null"); 622 schema->SetString("type", "null");
623 ExpectNotValid(TEST_SOURCE, 623 ExpectNotValid(TEST_SOURCE,
624 scoped_ptr<Value>(Value::CreateBooleanValue(false)).get(), 624 scoped_ptr<Value>(Value::CreateBooleanValue(false)).get(),
625 schema.get(), NULL, "", 625 schema.get(), NULL, "",
626 JSONSchemaValidator::FormatErrorMessage( 626 JSONSchemaValidator::FormatErrorMessage(
627 JSONSchemaValidator::kInvalidType, "null", "boolean")); 627 JSONSchemaValidator::kInvalidType, "null", "boolean"));
628 } 628 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698