OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 400 } |
401 | 401 |
402 | 402 |
403 VM_TEST_CASE(StringEncodeIRI) { | 403 VM_TEST_CASE(StringEncodeIRI) { |
404 const char* kInput = | 404 const char* kInput = |
405 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; | 405 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; |
406 const char* kOutput = | 406 const char* kOutput = |
407 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" | 407 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" |
408 "dart-repo%2Fdart%2Ftest.dart"; | 408 "dart-repo%2Fdart%2Ftest.dart"; |
409 const String& input = String::Handle(String::New(kInput)); | 409 const String& input = String::Handle(String::New(kInput)); |
410 const String& output = String::Handle(String::New(kOutput)); | 410 const char* encoded = String::EncodeIRI(input); |
411 const String& encoded = String::Handle(String::EncodeIRI(input)); | 411 EXPECT(strcmp(encoded, kOutput) == 0); |
412 EXPECT(output.Equals(encoded)); | |
413 } | 412 } |
414 | 413 |
415 | 414 |
416 VM_TEST_CASE(StringDecodeIRI) { | 415 VM_TEST_CASE(StringDecodeIRI) { |
417 const char* kOutput = | 416 const char* kOutput = |
418 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; | 417 "file:///usr/local/johnmccutchan/workspace/dart-repo/dart/test.dart"; |
419 const char* kInput = | 418 const char* kInput = |
420 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" | 419 "file%3A%2F%2F%2Fusr%2Flocal%2Fjohnmccutchan%2Fworkspace%2F" |
421 "dart-repo%2Fdart%2Ftest.dart"; | 420 "dart-repo%2Fdart%2Ftest.dart"; |
422 const String& input = String::Handle(String::New(kInput)); | 421 const String& input = String::Handle(String::New(kInput)); |
(...skipping 19 matching lines...) Expand all Loading... |
442 | 441 |
443 | 442 |
444 VM_TEST_CASE(StringIRITwoByte) { | 443 VM_TEST_CASE(StringIRITwoByte) { |
445 const intptr_t kInputLen = 3; | 444 const intptr_t kInputLen = 3; |
446 const uint16_t kInput[kInputLen] = { 'x', '/', 256 }; | 445 const uint16_t kInput[kInputLen] = { 'x', '/', 256 }; |
447 const String& input = String::Handle(String::FromUTF16(kInput, kInputLen)); | 446 const String& input = String::Handle(String::FromUTF16(kInput, kInputLen)); |
448 const intptr_t kOutputLen = 10; | 447 const intptr_t kOutputLen = 10; |
449 const uint16_t kOutput[kOutputLen] = | 448 const uint16_t kOutput[kOutputLen] = |
450 { 'x', '%', '2', 'F', '%', 'C', '4', '%', '8', '0' }; | 449 { 'x', '%', '2', 'F', '%', 'C', '4', '%', '8', '0' }; |
451 const String& output = String::Handle(String::FromUTF16(kOutput, kOutputLen)); | 450 const String& output = String::Handle(String::FromUTF16(kOutput, kOutputLen)); |
452 const String& encoded = String::Handle(String::EncodeIRI(input)); | 451 const String& encoded = String::Handle(String::New(String::EncodeIRI(input))); |
453 EXPECT(output.Equals(encoded)); | 452 EXPECT(output.Equals(encoded)); |
454 const String& decoded = String::Handle(String::DecodeIRI(output)); | 453 const String& decoded = String::Handle(String::DecodeIRI(output)); |
455 EXPECT(input.Equals(decoded)); | 454 EXPECT(input.Equals(decoded)); |
456 } | 455 } |
457 | 456 |
458 | 457 |
459 VM_TEST_CASE(Mint) { | 458 VM_TEST_CASE(Mint) { |
460 // On 64-bit architectures a Smi is stored in a 64 bit word. A Midint cannot | 459 // On 64-bit architectures a Smi is stored in a 64 bit word. A Midint cannot |
461 // be allocated if it does fit into a Smi. | 460 // be allocated if it does fit into a Smi. |
462 #if !defined(ARCH_IS_64_BIT) | 461 #if !defined(ARCH_IS_64_BIT) |
(...skipping 4258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4721 String& test = String::Handle(); | 4720 String& test = String::Handle(); |
4722 String& result = String::Handle(); | 4721 String& result = String::Handle(); |
4723 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { | 4722 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { |
4724 test = String::New(tests[i].in); | 4723 test = String::New(tests[i].in); |
4725 result = String::ScrubName(test); | 4724 result = String::ScrubName(test); |
4726 EXPECT_STREQ(tests[i].out, result.ToCString()); | 4725 EXPECT_STREQ(tests[i].out, result.ToCString()); |
4727 } | 4726 } |
4728 } | 4727 } |
4729 | 4728 |
4730 } // namespace dart | 4729 } // namespace dart |
OLD | NEW |