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

Side by Side Diff: components/json_schema/json_schema_validator_unittest_base.cc

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/json_schema/json_schema_validator_unittest_base.h" 5 #include "components/json_schema/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 #include <memory> 10 #include <memory>
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 void JSONSchemaValidatorTestBase::TestEnum() { 140 void JSONSchemaValidatorTestBase::TestEnum() {
141 std::unique_ptr<base::DictionaryValue> schema( 141 std::unique_ptr<base::DictionaryValue> schema(
142 LoadDictionary("enum_schema.json")); 142 LoadDictionary("enum_schema.json"));
143 143
144 ExpectValid(TEST_SOURCE, 144 ExpectValid(TEST_SOURCE,
145 std::unique_ptr<base::Value>(new base::StringValue("foo")).get(), 145 std::unique_ptr<base::Value>(new base::StringValue("foo")).get(),
146 schema.get(), NULL); 146 schema.get(), NULL);
147 ExpectValid( 147 ExpectValid(
148 TEST_SOURCE, 148 TEST_SOURCE,
149 std::unique_ptr<base::Value>(new base::FundamentalValue(42)).get(), 149 std::unique_ptr<base::Value>(new base::Value(42)).get(),
150 schema.get(), NULL); 150 schema.get(), NULL);
151 ExpectValid( 151 ExpectValid(
152 TEST_SOURCE, 152 TEST_SOURCE,
153 std::unique_ptr<base::Value>(new base::FundamentalValue(false)).get(), 153 std::unique_ptr<base::Value>(new base::Value(false)).get(),
154 schema.get(), NULL); 154 schema.get(), NULL);
155 155
156 ExpectNotValid( 156 ExpectNotValid(
157 TEST_SOURCE, 157 TEST_SOURCE,
158 std::unique_ptr<base::Value>(new base::StringValue("42")).get(), 158 std::unique_ptr<base::Value>(new base::StringValue("42")).get(),
159 schema.get(), NULL, std::string(), JSONSchemaValidator::kInvalidEnum); 159 schema.get(), NULL, std::string(), JSONSchemaValidator::kInvalidEnum);
160 ExpectNotValid(TEST_SOURCE, base::Value::CreateNullValue().get(), 160 ExpectNotValid(TEST_SOURCE, base::Value::CreateNullValue().get(),
161 schema.get(), NULL, std::string(), 161 schema.get(), NULL, std::string(),
162 JSONSchemaValidator::kInvalidEnum); 162 JSONSchemaValidator::kInvalidEnum);
163 } 163 }
164 164
165 void JSONSchemaValidatorTestBase::TestChoices() { 165 void JSONSchemaValidatorTestBase::TestChoices() {
166 std::unique_ptr<base::DictionaryValue> schema( 166 std::unique_ptr<base::DictionaryValue> schema(
167 LoadDictionary("choices_schema.json")); 167 LoadDictionary("choices_schema.json"));
168 168
169 ExpectValid(TEST_SOURCE, base::Value::CreateNullValue().get(), schema.get(), 169 ExpectValid(TEST_SOURCE, base::Value::CreateNullValue().get(), schema.get(),
170 NULL); 170 NULL);
171 ExpectValid( 171 ExpectValid(
172 TEST_SOURCE, 172 TEST_SOURCE,
173 std::unique_ptr<base::Value>(new base::FundamentalValue(42)).get(), 173 std::unique_ptr<base::Value>(new base::Value(42)).get(),
174 schema.get(), NULL); 174 schema.get(), NULL);
175 175
176 std::unique_ptr<base::DictionaryValue> instance(new base::DictionaryValue()); 176 std::unique_ptr<base::DictionaryValue> instance(new base::DictionaryValue());
177 instance->SetString("foo", "bar"); 177 instance->SetString("foo", "bar");
178 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 178 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
179 179
180 ExpectNotValid( 180 ExpectNotValid(
181 TEST_SOURCE, 181 TEST_SOURCE,
182 std::unique_ptr<base::Value>(new base::StringValue("foo")).get(), 182 std::unique_ptr<base::Value>(new base::StringValue("foo")).get(),
183 schema.get(), NULL, std::string(), JSONSchemaValidator::kInvalidChoice); 183 schema.get(), NULL, std::string(), JSONSchemaValidator::kInvalidChoice);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 NULL, 398 NULL,
399 std::string(), 399 std::string(),
400 JSONSchemaValidator::FormatErrorMessage( 400 JSONSchemaValidator::FormatErrorMessage(
401 JSONSchemaValidator::kArrayMaxItems, "2")); 401 JSONSchemaValidator::kArrayMaxItems, "2"));
402 402
403 instance->Remove(1, NULL); 403 instance->Remove(1, NULL);
404 instance->Remove(1, NULL); 404 instance->Remove(1, NULL);
405 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1", 405 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1",
406 JSONSchemaValidator::kArrayItemRequired); 406 JSONSchemaValidator::kArrayItemRequired);
407 407
408 instance->Set(0, new base::FundamentalValue(42)); 408 instance->Set(0, new base::Value(42));
409 instance->AppendInteger(42); 409 instance->AppendInteger(42);
410 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "0", 410 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "0",
411 JSONSchemaValidator::FormatErrorMessage( 411 JSONSchemaValidator::FormatErrorMessage(
412 JSONSchemaValidator::kInvalidType, 412 JSONSchemaValidator::kInvalidType,
413 schema::kString, 413 schema::kString,
414 schema::kInteger)); 414 schema::kInteger));
415 415
416 base::DictionaryValue* additional_properties = new base::DictionaryValue(); 416 base::DictionaryValue* additional_properties = new base::DictionaryValue();
417 additional_properties->SetString(schema::kType, schema::kAny); 417 additional_properties->SetString(schema::kType, schema::kAny);
418 schema->Set(schema::kAdditionalProperties, additional_properties); 418 schema->Set(schema::kAdditionalProperties, additional_properties);
419 instance->Set(0, new base::StringValue("42")); 419 instance->Set(0, new base::StringValue("42"));
420 instance->AppendString("anything"); 420 instance->AppendString("anything");
421 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 421 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
422 instance->Set(2, new base::ListValue()); 422 instance->Set(2, new base::ListValue());
423 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 423 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
424 424
425 additional_properties->SetString(schema::kType, schema::kBoolean); 425 additional_properties->SetString(schema::kType, schema::kBoolean);
426 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "2", 426 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "2",
427 JSONSchemaValidator::FormatErrorMessage( 427 JSONSchemaValidator::FormatErrorMessage(
428 JSONSchemaValidator::kInvalidType, 428 JSONSchemaValidator::kInvalidType,
429 schema::kBoolean, 429 schema::kBoolean,
430 schema::kArray)); 430 schema::kArray));
431 instance->Set(2, new base::FundamentalValue(false)); 431 instance->Set(2, new base::Value(false));
432 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 432 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
433 433
434 base::ListValue* items_schema = NULL; 434 base::ListValue* items_schema = NULL;
435 base::DictionaryValue* item0_schema = NULL; 435 base::DictionaryValue* item0_schema = NULL;
436 ASSERT_TRUE(schema->GetList(schema::kItems, &items_schema)); 436 ASSERT_TRUE(schema->GetList(schema::kItems, &items_schema));
437 ASSERT_TRUE(items_schema->GetDictionary(0, &item0_schema)); 437 ASSERT_TRUE(items_schema->GetDictionary(0, &item0_schema));
438 item0_schema->SetBoolean(schema::kOptional, true); 438 item0_schema->SetBoolean(schema::kOptional, true);
439 instance->Remove(2, NULL); 439 instance->Remove(2, NULL);
440 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 440 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
441 // TODO(aa): I think this is inconsistent with the handling of NULL+optional 441 // TODO(aa): I think this is inconsistent with the handling of NULL+optional
442 // for objects. 442 // for objects.
443 instance->Set(0, base::Value::CreateNullValue()); 443 instance->Set(0, base::Value::CreateNullValue());
444 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 444 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
445 instance->Set(0, new base::FundamentalValue(42)); 445 instance->Set(0, new base::Value(42));
446 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "0", 446 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "0",
447 JSONSchemaValidator::FormatErrorMessage( 447 JSONSchemaValidator::FormatErrorMessage(
448 JSONSchemaValidator::kInvalidType, 448 JSONSchemaValidator::kInvalidType,
449 schema::kString, 449 schema::kString,
450 schema::kInteger)); 450 schema::kInteger));
451 } 451 }
452 452
453 void JSONSchemaValidatorTestBase::TestArrayNonTuple() { 453 void JSONSchemaValidatorTestBase::TestArrayNonTuple() {
454 std::unique_ptr<base::DictionaryValue> schema(new base::DictionaryValue()); 454 std::unique_ptr<base::DictionaryValue> schema(new base::DictionaryValue());
455 schema->SetString(schema::kType, schema::kArray); 455 schema->SetString(schema::kType, schema::kArray);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 522 }
523 523
524 void JSONSchemaValidatorTestBase::TestNumber() { 524 void JSONSchemaValidatorTestBase::TestNumber() {
525 std::unique_ptr<base::DictionaryValue> schema(new base::DictionaryValue()); 525 std::unique_ptr<base::DictionaryValue> schema(new base::DictionaryValue());
526 schema->SetString(schema::kType, schema::kNumber); 526 schema->SetString(schema::kType, schema::kNumber);
527 schema->SetInteger(schema::kMinimum, 1); 527 schema->SetInteger(schema::kMinimum, 1);
528 schema->SetInteger(schema::kMaximum, 100); 528 schema->SetInteger(schema::kMaximum, 100);
529 schema->SetInteger("maxDecimal", 2); 529 schema->SetInteger("maxDecimal", 2);
530 530
531 ExpectValid(TEST_SOURCE, 531 ExpectValid(TEST_SOURCE,
532 std::unique_ptr<base::Value>(new base::FundamentalValue(1)).get(), 532 std::unique_ptr<base::Value>(new base::Value(1)).get(),
533 schema.get(), NULL); 533 schema.get(), NULL);
534 ExpectValid( 534 ExpectValid(
535 TEST_SOURCE, 535 TEST_SOURCE,
536 std::unique_ptr<base::Value>(new base::FundamentalValue(50)).get(), 536 std::unique_ptr<base::Value>(new base::Value(50)).get(),
537 schema.get(), NULL); 537 schema.get(), NULL);
538 ExpectValid( 538 ExpectValid(
539 TEST_SOURCE, 539 TEST_SOURCE,
540 std::unique_ptr<base::Value>(new base::FundamentalValue(100)).get(), 540 std::unique_ptr<base::Value>(new base::Value(100)).get(),
541 schema.get(), NULL); 541 schema.get(), NULL);
542 ExpectValid( 542 ExpectValid(
543 TEST_SOURCE, 543 TEST_SOURCE,
544 std::unique_ptr<base::Value>(new base::FundamentalValue(88.88)).get(), 544 std::unique_ptr<base::Value>(new base::Value(88.88)).get(),
545 schema.get(), NULL); 545 schema.get(), NULL);
546 546
547 ExpectNotValid( 547 ExpectNotValid(
548 TEST_SOURCE, 548 TEST_SOURCE,
549 std::unique_ptr<base::Value>(new base::FundamentalValue(0.5)).get(), 549 std::unique_ptr<base::Value>(new base::Value(0.5)).get(),
550 schema.get(), NULL, std::string(), 550 schema.get(), NULL, std::string(),
551 JSONSchemaValidator::FormatErrorMessage( 551 JSONSchemaValidator::FormatErrorMessage(
552 JSONSchemaValidator::kNumberMinimum, "1")); 552 JSONSchemaValidator::kNumberMinimum, "1"));
553 ExpectNotValid( 553 ExpectNotValid(
554 TEST_SOURCE, 554 TEST_SOURCE,
555 std::unique_ptr<base::Value>(new base::FundamentalValue(100.1)).get(), 555 std::unique_ptr<base::Value>(new base::Value(100.1)).get(),
556 schema.get(), NULL, std::string(), 556 schema.get(), NULL, std::string(),
557 JSONSchemaValidator::FormatErrorMessage( 557 JSONSchemaValidator::FormatErrorMessage(
558 JSONSchemaValidator::kNumberMaximum, "100")); 558 JSONSchemaValidator::kNumberMaximum, "100"));
559 } 559 }
560 560
561 void JSONSchemaValidatorTestBase::TestTypeClassifier() { 561 void JSONSchemaValidatorTestBase::TestTypeClassifier() {
562 EXPECT_EQ(std::string(schema::kBoolean), 562 EXPECT_EQ(std::string(schema::kBoolean),
563 JSONSchemaValidator::GetJSONSchemaType( 563 JSONSchemaValidator::GetJSONSchemaType(
564 std::unique_ptr<base::Value>(new base::FundamentalValue(true)) 564 std::unique_ptr<base::Value>(new base::Value(true))
565 .get())); 565 .get()));
566 EXPECT_EQ(std::string(schema::kBoolean), 566 EXPECT_EQ(std::string(schema::kBoolean),
567 JSONSchemaValidator::GetJSONSchemaType( 567 JSONSchemaValidator::GetJSONSchemaType(
568 std::unique_ptr<base::Value>(new base::FundamentalValue(false)) 568 std::unique_ptr<base::Value>(new base::Value(false))
569 .get())); 569 .get()));
570 570
571 // It doesn't matter whether the C++ type is 'integer' or 'real'. If the 571 // It doesn't matter whether the C++ type is 'integer' or 'real'. If the
572 // number is integral and within the representable range of integers in 572 // number is integral and within the representable range of integers in
573 // double, it's classified as 'integer'. 573 // double, it's classified as 'integer'.
574 EXPECT_EQ( 574 EXPECT_EQ(
575 std::string(schema::kInteger), 575 std::string(schema::kInteger),
576 JSONSchemaValidator::GetJSONSchemaType( 576 JSONSchemaValidator::GetJSONSchemaType(
577 std::unique_ptr<base::Value>(new base::FundamentalValue(42)).get())); 577 std::unique_ptr<base::Value>(new base::Value(42)).get()));
578 EXPECT_EQ( 578 EXPECT_EQ(
579 std::string(schema::kInteger), 579 std::string(schema::kInteger),
580 JSONSchemaValidator::GetJSONSchemaType( 580 JSONSchemaValidator::GetJSONSchemaType(
581 std::unique_ptr<base::Value>(new base::FundamentalValue(0)).get())); 581 std::unique_ptr<base::Value>(new base::Value(0)).get()));
582 EXPECT_EQ( 582 EXPECT_EQ(
583 std::string(schema::kInteger), 583 std::string(schema::kInteger),
584 JSONSchemaValidator::GetJSONSchemaType( 584 JSONSchemaValidator::GetJSONSchemaType(
585 std::unique_ptr<base::Value>(new base::FundamentalValue(42)).get())); 585 std::unique_ptr<base::Value>(new base::Value(42)).get()));
586 EXPECT_EQ(std::string(schema::kInteger), 586 EXPECT_EQ(std::string(schema::kInteger),
587 JSONSchemaValidator::GetJSONSchemaType( 587 JSONSchemaValidator::GetJSONSchemaType(
588 std::unique_ptr<base::Value>( 588 std::unique_ptr<base::Value>(
589 new base::FundamentalValue(pow(2.0, DBL_MANT_DIG))) 589 new base::Value(pow(2.0, DBL_MANT_DIG)))
590 .get())); 590 .get()));
591 EXPECT_EQ(std::string(schema::kInteger), 591 EXPECT_EQ(std::string(schema::kInteger),
592 JSONSchemaValidator::GetJSONSchemaType( 592 JSONSchemaValidator::GetJSONSchemaType(
593 std::unique_ptr<base::Value>( 593 std::unique_ptr<base::Value>(
594 new base::FundamentalValue(pow(-2.0, DBL_MANT_DIG))) 594 new base::Value(pow(-2.0, DBL_MANT_DIG)))
595 .get())); 595 .get()));
596 596
597 // "number" is only used for non-integral numbers, or numbers beyond what 597 // "number" is only used for non-integral numbers, or numbers beyond what
598 // double can accurately represent. 598 // double can accurately represent.
599 EXPECT_EQ(std::string(schema::kNumber), 599 EXPECT_EQ(std::string(schema::kNumber),
600 JSONSchemaValidator::GetJSONSchemaType( 600 JSONSchemaValidator::GetJSONSchemaType(
601 std::unique_ptr<base::Value>(new base::FundamentalValue(88.8)) 601 std::unique_ptr<base::Value>(new base::Value(88.8))
602 .get())); 602 .get()));
603 EXPECT_EQ(std::string(schema::kNumber), 603 EXPECT_EQ(std::string(schema::kNumber),
604 JSONSchemaValidator::GetJSONSchemaType( 604 JSONSchemaValidator::GetJSONSchemaType(
605 std::unique_ptr<base::Value>( 605 std::unique_ptr<base::Value>(
606 new base::FundamentalValue(pow(2.0, DBL_MANT_DIG) * 2)) 606 new base::Value(pow(2.0, DBL_MANT_DIG) * 2))
607 .get())); 607 .get()));
608 EXPECT_EQ(std::string(schema::kNumber), 608 EXPECT_EQ(std::string(schema::kNumber),
609 JSONSchemaValidator::GetJSONSchemaType( 609 JSONSchemaValidator::GetJSONSchemaType(
610 std::unique_ptr<base::Value>( 610 std::unique_ptr<base::Value>(
611 new base::FundamentalValue(pow(-2.0, DBL_MANT_DIG) * 2)) 611 new base::Value(pow(-2.0, DBL_MANT_DIG) * 2))
612 .get())); 612 .get()));
613 613
614 EXPECT_EQ( 614 EXPECT_EQ(
615 std::string(schema::kString), 615 std::string(schema::kString),
616 JSONSchemaValidator::GetJSONSchemaType( 616 JSONSchemaValidator::GetJSONSchemaType(
617 std::unique_ptr<base::Value>(new base::StringValue("foo")).get())); 617 std::unique_ptr<base::Value>(new base::StringValue("foo")).get()));
618 EXPECT_EQ(std::string(schema::kArray), 618 EXPECT_EQ(std::string(schema::kArray),
619 JSONSchemaValidator::GetJSONSchemaType( 619 JSONSchemaValidator::GetJSONSchemaType(
620 std::unique_ptr<base::Value>(new base::ListValue()).get())); 620 std::unique_ptr<base::Value>(new base::ListValue()).get()));
621 EXPECT_EQ( 621 EXPECT_EQ(
(...skipping 21 matching lines...) Expand all
643 643
644 schema->SetString(schema::kType, schema::kString); 644 schema->SetString(schema::kType, schema::kString);
645 ExpectValid( 645 ExpectValid(
646 TEST_SOURCE, 646 TEST_SOURCE,
647 std::unique_ptr<base::Value>(new base::StringValue("foobar")).get(), 647 std::unique_ptr<base::Value>(new base::StringValue("foobar")).get(),
648 schema.get(), NULL); 648 schema.get(), NULL);
649 649
650 schema->SetString(schema::kType, schema::kNumber); 650 schema->SetString(schema::kType, schema::kNumber);
651 ExpectValid( 651 ExpectValid(
652 TEST_SOURCE, 652 TEST_SOURCE,
653 std::unique_ptr<base::Value>(new base::FundamentalValue(88.8)).get(), 653 std::unique_ptr<base::Value>(new base::Value(88.8)).get(),
654 schema.get(), NULL); 654 schema.get(), NULL);
655 ExpectValid( 655 ExpectValid(
656 TEST_SOURCE, 656 TEST_SOURCE,
657 std::unique_ptr<base::Value>(new base::FundamentalValue(42)).get(), 657 std::unique_ptr<base::Value>(new base::Value(42)).get(),
658 schema.get(), NULL); 658 schema.get(), NULL);
659 ExpectValid( 659 ExpectValid(
660 TEST_SOURCE, 660 TEST_SOURCE,
661 std::unique_ptr<base::Value>(new base::FundamentalValue(42)).get(), 661 std::unique_ptr<base::Value>(new base::Value(42)).get(),
662 schema.get(), NULL); 662 schema.get(), NULL);
663 ExpectValid(TEST_SOURCE, 663 ExpectValid(TEST_SOURCE,
664 std::unique_ptr<base::Value>(new base::FundamentalValue(0)).get(), 664 std::unique_ptr<base::Value>(new base::Value(0)).get(),
665 schema.get(), NULL); 665 schema.get(), NULL);
666 666
667 schema->SetString(schema::kType, schema::kInteger); 667 schema->SetString(schema::kType, schema::kInteger);
668 ExpectValid( 668 ExpectValid(
669 TEST_SOURCE, 669 TEST_SOURCE,
670 std::unique_ptr<base::Value>(new base::FundamentalValue(42)).get(), 670 std::unique_ptr<base::Value>(new base::Value(42)).get(),
671 schema.get(), NULL); 671 schema.get(), NULL);
672 ExpectValid( 672 ExpectValid(
673 TEST_SOURCE, 673 TEST_SOURCE,
674 std::unique_ptr<base::Value>(new base::FundamentalValue(42)).get(), 674 std::unique_ptr<base::Value>(new base::Value(42)).get(),
675 schema.get(), NULL); 675 schema.get(), NULL);
676 ExpectValid(TEST_SOURCE, 676 ExpectValid(TEST_SOURCE,
677 std::unique_ptr<base::Value>(new base::FundamentalValue(0)).get(), 677 std::unique_ptr<base::Value>(new base::Value(0)).get(),
678 schema.get(), NULL); 678 schema.get(), NULL);
679 ExpectValid(TEST_SOURCE, 679 ExpectValid(TEST_SOURCE,
680 std::unique_ptr<base::Value>( 680 std::unique_ptr<base::Value>(
681 new base::FundamentalValue(pow(2.0, DBL_MANT_DIG))) 681 new base::Value(pow(2.0, DBL_MANT_DIG)))
682 .get(), 682 .get(),
683 schema.get(), NULL); 683 schema.get(), NULL);
684 ExpectValid(TEST_SOURCE, 684 ExpectValid(TEST_SOURCE,
685 std::unique_ptr<base::Value>( 685 std::unique_ptr<base::Value>(
686 new base::FundamentalValue(pow(-2.0, DBL_MANT_DIG))) 686 new base::Value(pow(-2.0, DBL_MANT_DIG)))
687 .get(), 687 .get(),
688 schema.get(), NULL); 688 schema.get(), NULL);
689 689
690 schema->SetString(schema::kType, schema::kBoolean); 690 schema->SetString(schema::kType, schema::kBoolean);
691 ExpectValid( 691 ExpectValid(
692 TEST_SOURCE, 692 TEST_SOURCE,
693 std::unique_ptr<base::Value>(new base::FundamentalValue(false)).get(), 693 std::unique_ptr<base::Value>(new base::Value(false)).get(),
694 schema.get(), NULL); 694 schema.get(), NULL);
695 ExpectValid( 695 ExpectValid(
696 TEST_SOURCE, 696 TEST_SOURCE,
697 std::unique_ptr<base::Value>(new base::FundamentalValue(true)).get(), 697 std::unique_ptr<base::Value>(new base::Value(true)).get(),
698 schema.get(), NULL); 698 schema.get(), NULL);
699 699
700 schema->SetString(schema::kType, schema::kNull); 700 schema->SetString(schema::kType, schema::kNull);
701 ExpectValid(TEST_SOURCE, base::Value::CreateNullValue().get(), schema.get(), 701 ExpectValid(TEST_SOURCE, base::Value::CreateNullValue().get(), schema.get(),
702 NULL); 702 NULL);
703 703
704 // not valid 704 // not valid
705 schema->SetString(schema::kType, schema::kObject); 705 schema->SetString(schema::kType, schema::kObject);
706 ExpectNotValid( 706 ExpectNotValid(
707 TEST_SOURCE, std::unique_ptr<base::Value>(new base::ListValue()).get(), 707 TEST_SOURCE, std::unique_ptr<base::Value>(new base::ListValue()).get(),
708 schema.get(), NULL, std::string(), 708 schema.get(), NULL, std::string(),
709 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType, 709 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType,
710 schema::kObject, schema::kArray)); 710 schema::kObject, schema::kArray));
711 711
712 schema->SetString(schema::kType, schema::kObject); 712 schema->SetString(schema::kType, schema::kObject);
713 ExpectNotValid( 713 ExpectNotValid(
714 TEST_SOURCE, base::Value::CreateNullValue().get(), schema.get(), NULL, 714 TEST_SOURCE, base::Value::CreateNullValue().get(), schema.get(), NULL,
715 std::string(), 715 std::string(),
716 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType, 716 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType,
717 schema::kObject, schema::kNull)); 717 schema::kObject, schema::kNull));
718 718
719 schema->SetString(schema::kType, schema::kArray); 719 schema->SetString(schema::kType, schema::kArray);
720 ExpectNotValid( 720 ExpectNotValid(
721 TEST_SOURCE, 721 TEST_SOURCE,
722 std::unique_ptr<base::Value>(new base::FundamentalValue(42)).get(), 722 std::unique_ptr<base::Value>(new base::Value(42)).get(),
723 schema.get(), NULL, std::string(), 723 schema.get(), NULL, std::string(),
724 JSONSchemaValidator::FormatErrorMessage( 724 JSONSchemaValidator::FormatErrorMessage(
725 JSONSchemaValidator::kInvalidType, schema::kArray, schema::kInteger)); 725 JSONSchemaValidator::kInvalidType, schema::kArray, schema::kInteger));
726 726
727 schema->SetString(schema::kType, schema::kString); 727 schema->SetString(schema::kType, schema::kString);
728 ExpectNotValid( 728 ExpectNotValid(
729 TEST_SOURCE, 729 TEST_SOURCE,
730 std::unique_ptr<base::Value>(new base::FundamentalValue(42)).get(), 730 std::unique_ptr<base::Value>(new base::Value(42)).get(),
731 schema.get(), NULL, std::string(), 731 schema.get(), NULL, std::string(),
732 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType, 732 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType,
733 schema::kString, 733 schema::kString,
734 schema::kInteger)); 734 schema::kInteger));
735 735
736 schema->SetString(schema::kType, schema::kNumber); 736 schema->SetString(schema::kType, schema::kNumber);
737 ExpectNotValid( 737 ExpectNotValid(
738 TEST_SOURCE, 738 TEST_SOURCE,
739 std::unique_ptr<base::Value>(new base::StringValue("42")).get(), 739 std::unique_ptr<base::Value>(new base::StringValue("42")).get(),
740 schema.get(), NULL, std::string(), 740 schema.get(), NULL, std::string(),
741 JSONSchemaValidator::FormatErrorMessage( 741 JSONSchemaValidator::FormatErrorMessage(
742 JSONSchemaValidator::kInvalidType, schema::kNumber, schema::kString)); 742 JSONSchemaValidator::kInvalidType, schema::kNumber, schema::kString));
743 743
744 schema->SetString(schema::kType, schema::kInteger); 744 schema->SetString(schema::kType, schema::kInteger);
745 ExpectNotValid( 745 ExpectNotValid(
746 TEST_SOURCE, 746 TEST_SOURCE,
747 std::unique_ptr<base::Value>(new base::FundamentalValue(88.8)).get(), 747 std::unique_ptr<base::Value>(new base::Value(88.8)).get(),
748 schema.get(), NULL, std::string(), 748 schema.get(), NULL, std::string(),
749 JSONSchemaValidator::kInvalidTypeIntegerNumber); 749 JSONSchemaValidator::kInvalidTypeIntegerNumber);
750 750
751 schema->SetString(schema::kType, schema::kBoolean); 751 schema->SetString(schema::kType, schema::kBoolean);
752 ExpectNotValid( 752 ExpectNotValid(
753 TEST_SOURCE, 753 TEST_SOURCE,
754 std::unique_ptr<base::Value>(new base::FundamentalValue(1)).get(), 754 std::unique_ptr<base::Value>(new base::Value(1)).get(),
755 schema.get(), NULL, std::string(), 755 schema.get(), NULL, std::string(),
756 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType, 756 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType,
757 schema::kBoolean, 757 schema::kBoolean,
758 schema::kInteger)); 758 schema::kInteger));
759 759
760 schema->SetString(schema::kType, schema::kNull); 760 schema->SetString(schema::kType, schema::kNull);
761 ExpectNotValid( 761 ExpectNotValid(
762 TEST_SOURCE, 762 TEST_SOURCE,
763 std::unique_ptr<base::Value>(new base::FundamentalValue(false)).get(), 763 std::unique_ptr<base::Value>(new base::Value(false)).get(),
764 schema.get(), NULL, std::string(), 764 schema.get(), NULL, std::string(),
765 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType, 765 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType,
766 schema::kNull, schema::kBoolean)); 766 schema::kNull, schema::kBoolean));
767 } 767 }
OLDNEW
« no previous file with comments | « components/dom_distiller/ios/distiller_page_ios.mm ('k') | components/login/base_screen_handler_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698