예제 #1
0
 void testCopyConstructor1()
 {
   Sn stdfStr("ABC");
   TS_ASSERT_SAME_DATA(stdfStr.mData+2, "ABC", 3);
   TS_ASSERT_EQUALS(stdfStr.storage(), 5u);
   TS_ASSERT_EQUALS(stdfStr.max_size(), 65535u);
   Sn stdfStrC (stdfStr);
   TS_ASSERT_SAME_DATA(stdfStrC.mData+2, "ABC", 3);
   TS_ASSERT_EQUALS(stdfStrC.storage(), 5u);
   TS_ASSERT_EQUALS(stdfStrC.max_size(), 65535u);
 }
예제 #2
0
 void testConstructor2()
 {
   Sn stdfStr;
   TS_ASSERT_SAME_DATA(stdfStr.mData, "", 1);
   TS_ASSERT_EQUALS(stdfStr.storage(), 2u);
   TS_ASSERT_EQUALS(stdfStr.max_size(), 65535u);
   stdfStr += "";
   TS_ASSERT_SAME_DATA(stdfStr.mData, "", 1);
   TS_ASSERT_EQUALS(stdfStr.storage(), 2u);
   TS_ASSERT_EQUALS(stdfStr.max_size(), 65535u);
 }
예제 #3
0
 void testAssigner1()
 {
   Sn stdfStr("ABC");
   TS_ASSERT_SAME_DATA(stdfStr.mData+2, "ABC", 3);
   TS_ASSERT_EQUALS(stdfStr.storage(), 5u);
   TS_ASSERT_EQUALS(stdfStr.max_size(), 65535u);
   Sn stdfStrC;
   stdfStrC = stdfStr;
   TS_ASSERT_SAME_DATA(stdfStrC.mData+2, "ABC", 3);
   TS_ASSERT_EQUALS(stdfStrC.storage(), 5u);
   TS_ASSERT_EQUALS(stdfStrC.max_size(), 65535u);
 }
예제 #4
0
 void testCopyConstructor1()
 {
   B6 source("00000001");
   B6 stdfStr(source);
   unsigned char ch = 1;
   TS_ASSERT_SAME_DATA(stdfStr.mData, &ch, 1);
   TS_ASSERT_EQUALS(stdfStr[0], 1);
   TS_ASSERT_EQUALS(stdfStr.to_string(), std::basic_string<char>("000000000000000000000000000000000000000000000001"));
   stdfStr = "10000000";
   ch = 128;
   TS_ASSERT_SAME_DATA(stdfStr.mData, &ch, 1);
   TS_ASSERT_EQUALS(stdfStr.to_string(), std::basic_string<char>("000000000000000000000000000000000000000010000000"));
   TS_ASSERT_EQUALS(stdfStr[7], 1);
   TS_ASSERT_EQUALS(source.to_string(), std::basic_string<char>("000000000000000000000000000000000000000000000001"));
 }
예제 #5
0
    void test_to_chars() {
        String* s = String::create(state, "xy");
        ByteArray* b = s->data();
        char* chars = b->to_chars(state);

        TS_ASSERT_SAME_DATA("xy", chars, 2);
    }
예제 #6
0
  void test_to_chars() {
    String* s = String::create(state, "xy");
    CharArray* c = s->data();
    char* chars = c->to_chars(state, Fixnum::from(2));

    TS_ASSERT_SAME_DATA("xy", chars, 2);
  }
예제 #7
0
    void testWriteRead3()
    {
      const char *filename = "TestB6.testWriteRead3.txt";

      B6 stdfStrIn;
      stdfStrIn[0] = 1;
      stdfStrIn[6] = 1;
      stdfStrIn[26] = 1;
      std::ofstream outfile(filename, std::ofstream::binary);
      stdfStrIn.write(outfile);
      outfile.close();

      B6 stdfStrOut;
      std::ifstream infile(filename, std::ifstream::binary);
      stdfStrOut.read(infile);
      outfile.close();

      TS_ASSERT_SAME_DATA(stdfStrIn.mData, stdfStrOut.mData, SIZE);
      TS_ASSERT_EQUALS(stdfStrIn.to_string(), "000000000000000000000100000000000000000001000001");
      TS_ASSERT_EQUALS(stdfStrOut.to_string(), "000000000000000000000100000000000000000001000001");
      TS_ASSERT_EQUALS(stdfStrIn[0], 1);
      TS_ASSERT_EQUALS(stdfStrOut[0], 1);
      TS_ASSERT_EQUALS(stdfStrIn[6], 1);
      TS_ASSERT_EQUALS(stdfStrOut[6], 1);
      TS_ASSERT_EQUALS(stdfStrIn[26], 1);
      TS_ASSERT_EQUALS(stdfStrOut[26], 1);
      TS_ASSERT_EQUALS(stdfStrIn.storage(), SIZE);
      TS_ASSERT_EQUALS(stdfStrOut.storage(), SIZE);
    }
예제 #8
0
 void testConstructor2()
 {
   B6 stdfStr = "";
   unsigned char ch[SIZE] = {0};
   TS_ASSERT_SAME_DATA(stdfStr.mData, ch, SIZE);
   TS_ASSERT_EQUALS(stdfStr.to_string(), "000000000000000000000000000000000000000000000000");
   TS_ASSERT_EQUALS(stdfStr.storage(), SIZE);
 }
예제 #9
0
 void testConstructor3()
 {
   B6 stdfStr("0100000100100000001");
   unsigned char ch[SIZE] = {0};
   ch[0] = 1;
   ch[1] = 9;
   ch[2] = 2;
   
   TS_ASSERT_SAME_DATA(stdfStr.mData, ch, SIZE);
   TS_ASSERT_EQUALS(stdfStr.to_string(), std::basic_string<char>("000000000000000000000000000000100000100100000001"));
   stdfStr = "1000000000000001";
   memset(ch, 0, SIZE);
   ch[0] = 1;
   ch[1] = 128;
   TS_ASSERT_SAME_DATA(stdfStr.mData, ch, SIZE);
   TS_ASSERT_EQUALS(stdfStr.to_string(), std::basic_string<char>("000000000000000000000000000000001000000000000001"));
   stdfStr.reset(1);
   TS_ASSERT_EQUALS(stdfStr.to_string(), "111111111111111111111111111111111111111111111111");
   stdfStr.reset(0);
   TS_ASSERT_EQUALS(stdfStr.to_string(), "000000000000000000000000000000000000000000000000");
   stdfStr[0] = 1;
   TS_ASSERT_EQUALS(stdfStr.to_string(), "000000000000000000000000000000000000000000000001");
   TS_ASSERT_EQUALS(stdfStr[0], 1);
   TS_ASSERT_EQUALS(stdfStr[1], 0);
   TS_ASSERT_EQUALS(stdfStr[2], 0);
   TS_ASSERT_EQUALS(stdfStr[3], 0);
   TS_ASSERT_EQUALS(stdfStr[4], 0);
   TS_ASSERT_EQUALS(stdfStr[5], 0);
   TS_ASSERT_EQUALS(stdfStr[6], 0);
   TS_ASSERT_EQUALS(stdfStr[7], 0);
   TS_ASSERT_EQUALS(stdfStr[47], 0);
   stdfStr.reset(0);
   TS_ASSERT_EQUALS(stdfStr.to_string(), "000000000000000000000000000000000000000000000000");
   stdfStr[47] = 1;
   TS_ASSERT_EQUALS(stdfStr.to_string(), "100000000000000000000000000000000000000000000000");
   TS_ASSERT_EQUALS(stdfStr[0], 0);
   TS_ASSERT_EQUALS(stdfStr[1], 0);
   TS_ASSERT_EQUALS(stdfStr[2], 0);
   TS_ASSERT_EQUALS(stdfStr[3], 0);
   TS_ASSERT_EQUALS(stdfStr[4], 0);
   TS_ASSERT_EQUALS(stdfStr[5], 0);
   TS_ASSERT_EQUALS(stdfStr[6], 0);
   TS_ASSERT_EQUALS(stdfStr[7], 0);
   TS_ASSERT_EQUALS(stdfStr[47], 1);
 }
예제 #10
0
  void test_method_to_s_singleton() {
    Symbol* meth = state->symbol("meth");
    Symbol* klass = state->symbol("Object");

    profiler::Method method(0U, meth, klass, profiler::kSingleton);
    String* name = method.to_s(state);

    TS_ASSERT_SAME_DATA("Object.meth", name->byte_address(), 11);
  }
예제 #11
0
  void test_write() {
    char buf[4];

    String* s = String::create(state, "abdc");
    io->write(state, s);

    lseek(fd, 0, SEEK_SET);
    TS_ASSERT_EQUALS(::read(fd, buf, 4U), 4);
    TS_ASSERT_SAME_DATA(buf, "abdc", 4);
  }
예제 #12
0
    void testMerge()
    {
      Sn stdfStr;
      std::basic_string<char> str;

      str = "";
      stdfStr.clear();
      stdfStr += str;
      TS_ASSERT(stdfStr.to_string() == str);
      TS_ASSERT_SAME_DATA(stdfStr.mData, "", 1);

      str.clear();
      str.assign(stdfStr.max_size()+1, 'A');
      stdfStr.clear();
      stdfStr += str;
      str[0] = 0xFF;
      str[1] = 0xFF;
      TS_ASSERT_SAME_DATA(stdfStr.mData, str.data(), stdfStr.max_size()+1);

      str = "123456789";
      stdfStr.clear();
      stdfStr += str;
      TS_ASSERT(stdfStr.to_string() == str);
      str.insert(0, 2, 0x0);
      str[0] = 0x09;
      str[1] = 0x00;
      TS_ASSERT_SAME_DATA(stdfStr.mData, str.data(), str.size()+1);

      str.clear();
      str.assign(stdfStr.max_size()-5, 'A');
      stdfStr.clear();
      stdfStr += str;
      TS_ASSERT(stdfStr.to_string() == str);
      str.insert(0, 2, 0x0);
      str[0] = 0xFF-5;
      str[1] = 0xFF;
      TS_ASSERT_SAME_DATA(stdfStr.mData, str.data(), stdfStr.max_size()-4);
      std::basic_string<char> str1 = "123456789";
      stdfStr += str1;
      str[0] = 0xFF;
      str += str1;
      TS_ASSERT_SAME_DATA(stdfStr.mData, str.data(), stdfStr.max_size()+1);
    }
예제 #13
0
 void testClone1()
 {
   Sn stdfStr("ABC");
   TS_ASSERT_SAME_DATA(stdfStr.mData+2, "ABC", 3);
   TS_ASSERT_EQUALS(stdfStr.storage(), 5u);
   TS_ASSERT_EQUALS(stdfStr.max_size(), 65535u);
   DataType::DataTypeSharedPtr stdfStrP = stdfStr.clone();
   TS_ASSERT(stdfStrP->to_string() == "ABC");
   TS_ASSERT_EQUALS(stdfStrP->storage(), 5u);
   TS_ASSERT_DIFFERS(stdfStrP.get(), &stdfStr);
 }
예제 #14
0
  void test_control_seeks_to_a_known_position() {
    char *dir = make_directory();
    String* path = String::create(state, dir);
    d->open(state, path);
    d->read(state);
    Fixnum* pos = (Fixnum*)d->control(state, Fixnum::from(2), Fixnum::from(0));
    String* first = as<String>(d->read(state));

    d->control(state, Fixnum::from(0), pos);
    String* second = as<String>(d->read(state));
    TS_ASSERT_EQUALS(first->size(), second->size());
    TS_ASSERT_SAME_DATA(first, second, first->size());
    remove_directory(dir);
  }
예제 #15
0
    void testWriteRead2()
    {
      const char *filename = "TestB6.testWriteRead2.txt";

      B6 stdfStrIn("11111111000000011111111");
      std::ofstream outfile(filename, std::ofstream::binary);
      stdfStrIn.write(outfile);
      outfile.close();

      B6 stdfStrOut;
      std::ifstream infile(filename, std::ifstream::binary);
      stdfStrOut.read(infile);
      outfile.close();

      TS_ASSERT_SAME_DATA(stdfStrIn.mData, stdfStrOut.mData, SIZE);
      TS_ASSERT_EQUALS(stdfStrIn.to_string(), "000000000000000000000000011111111000000011111111");
      TS_ASSERT_EQUALS(stdfStrOut.to_string(), "000000000000000000000000011111111000000011111111");
    }
예제 #16
0
 void test_move_bytes() {
   String* s = String::create(state, "xyzzy");
   CharArray* c = s->data();
   c->move_bytes(state, Fixnum::from(0), Fixnum::from(2), Fixnum::from(3));
   TS_ASSERT_SAME_DATA(c->raw_bytes(), "xyzxy", 5);
 }
예제 #17
0
 void test_fetch_bytes() {
   String* s = String::create(state, "xyzzy");
   CharArray* c = s->data();
   CharArray* ca = c->fetch_bytes(state, Fixnum::from(1), Fixnum::from(3));
   TS_ASSERT_SAME_DATA(ca->raw_bytes(), "yzz", 3);
 }
예제 #18
0
 void test_move_bytes() {
   ByteArray* b = new_bytearray("xyzzy");
   b->move_bytes(state, Fixnum::from(0), Fixnum::from(2), Fixnum::from(3));
   TS_ASSERT_SAME_DATA(b->raw_bytes(), "xyzxy", 5);
 }
예제 #19
0
 void test_fetch_bytes() {
     String* s = String::create(state, "xyzzy");
     ByteArray* b = s->data();
     ByteArray* ba = b->fetch_bytes(state, Fixnum::from(1), Fixnum::from(3));
     TS_ASSERT_SAME_DATA(ba->bytes, "yzz", 3);
 }
예제 #20
0
 void test_move_bytes() {
     String* s = String::create(state, "xyzzy");
     ByteArray* b = s->data();
     b->move_bytes(state, Fixnum::from(0), Fixnum::from(2), Fixnum::from(3));
     TS_ASSERT_SAME_DATA(b->bytes, "xyzxy", 5);
 }
예제 #21
0
 void test_fetch_bytes() {
   ByteArray* b = new_bytearray("xyzzy");
   ByteArray* ba = b->fetch_bytes(state, Fixnum::from(1), Fixnum::from(3));
   TS_ASSERT_SAME_DATA(ba->raw_bytes(), "yzz", 3);
 }