Exemple #1
0
TEST(SegmentTest, constructors)
{
  {
    RAJA::RangeStrideSegment first(0, 10, 2);
    RAJA::RangeStrideSegment copied(first);
    ASSERT_EQ(first, copied);
    RAJA::RangeStrideSegment moved(std::move(first));
    ASSERT_EQ(moved, copied);
  }

  {
    RAJA::RangeSegment first(0, 10);
    RAJA::RangeSegment copied(first);
    ASSERT_EQ(first, copied);
    RAJA::RangeSegment moved(std::move(first));
    ASSERT_EQ(moved, copied);
  }

  {
    RAJA::ListSegment first(RAJA::RangeSegment(0, 10));
    ASSERT_EQ(RAJA::Owned, first.getIndexOwnership());

    RAJA::ListSegment copied(first);
    ASSERT_EQ(RAJA::Owned, copied.getIndexOwnership());

    ASSERT_EQ(first, copied);
    RAJA::ListSegment moved(std::move(first));
    ASSERT_EQ(moved, copied);

    RAJA::ListSegment empty(nullptr, 100);
    RAJA::ListSegment empty2(first.begin(), -5);
    ASSERT_EQ(empty, empty2);
  }
}
Exemple #2
0
TEST(ByteArrayTest, TestEmptyEqual) {
	mumble::ByteArray empty1(1);
	mumble::ByteArray empty2(1);

	empty1.Truncate(0);
	empty2.Truncate(0);

	EXPECT_EQ(empty1, empty2);
}
Exemple #3
0
// main()
int main (void) {
	int i = 0;
	int field_count = 0;
	char* name1 = "PEOPLE";
	char* name2 = "QTY";
	char* name3 = "Things";
	char* val1 = "12";
	char* val2 = "4";
	char* val3 = "All of them";
	struct Field* fields = calloc(6, FIELD_SIZE);
	fields->name = NULL;	

	empty2();

	fields = addField(name1, val1, 'T', field_count, fields);
	field_count++;
	fields = addField(name2, val2, 'D', field_count, fields);
	field_count++;
	fields = addField(name3, val3, 'I', field_count, fields);
	field_count++;

	/*	
	i=0;
	(fields+i)->name = "People";
	(fields+i)->value = "12";
	(fields+i)->fieldType = 'T';
	i++;	
	(fields+i)->name = "QTY";
	(fields+i)->value = "4";
	(fields+i)->fieldType = 'D';
	i++;
	(fields+i)->name = "Things";
	(fields+i)->value = "All of them";
	(fields+i)->fieldType = 'I';
	i++;
	(fields+i)->name = "Hats";
	(fields+i)->value = "Fedora";
	(fields+i)->fieldType = 'T';
	i++;
	(fields+i)->name = "Woop";
	(fields+i)->value = "above";
	(fields+i)->fieldType = 'D';
	i++;
	*/	

	empty();
	
	return 0;

} // end mainf()
Exemple #4
0
void testmain(void) {
    print("function");

    expect(77, t1());
    t2(79);
    t3(1, 2, 3, 4, 5, 6);
    t4();
    t5();
    expect(3, t6());
    expect(12, t7(3, 4));
    t8(23);
    t9();
    expect(7, t10(3, 4.0));
    func_ptr_call();
    func_name();
    empty();
    empty2();
    test_bool();
    test_struct();
}
Exemple #5
0
void testmain() {
    print("function");

    expect(77, t1());
    t2(79);
    t3(1, 2, 3, 4, 5, 6);
    t4();
    t5();
    expect(3, t6());
    expect(12, t7(3, 4));
    expect(77, (1 ? t1 : t6)());
    expect(3, (0 ? t1 : t6)());
    t8(23);
    t9();
    expect(7, t10(3, 4.0));
    func_ptr_call();
    func_name();
    local_static();
    empty();
    empty2();
    test_bool();
    test_struct();
    test_funcdesg();
}
Exemple #6
0
void TestTwine009Compare_ToTwine()
{
	BEGIN_TEST_METHOD( "TestTwine009Compare_ToTwine" )
	
	twine empty1;
	twine empty2;
	twine short1 = "Something Short";
	twine short2 = "Something Short";
	twine long1 = "Something A Bit Longer that Will cause us to allocate memory";
	twine long2 = "Something A Bit Longer that Will cause us to allocate memory";

	// Ensure that everything has different data pointers:
	ASSERT_NOTEQUALS( empty1(), empty2(), "empty1 and empty2 point to the same memory");
	ASSERT_NOTEQUALS( short1(), short2(), "short1 and short2 point to the same memory");
	ASSERT_NOTEQUALS( long1(), long2(), "long1 and long2 point to the same memory");

	ASSERT_EQUALS( 0, empty1.compare( empty2 ), "empty1.compare( empty2 ) != 0");
	ASSERT_NOTEQUALS( 0, empty1.compare( short1 ), "empty1.compare( short1 ) == 0");
	ASSERT_NOTEQUALS( 0, empty1.compare( short2 ), "empty1.compare( short2 ) == 0");
	ASSERT_NOTEQUALS( 0, empty1.compare( long1 ), "empty1.compare( long1) == 0");
	ASSERT_NOTEQUALS( 0, empty1.compare( long2 ), "empty1.compare( long2) == 0");

	ASSERT_EQUALS( 0, short1.compare( short2 ), "short1.compare( short2 ) != 0");
	ASSERT_NOTEQUALS( 0, short1.compare( empty1 ), "short1.compare( empty1 ) == 0");
	ASSERT_NOTEQUALS( 0, short1.compare( empty2), "short1.compare( empty2) == 0");
	ASSERT_NOTEQUALS( 0, short1.compare( long1 ), "short1.compare( long1) == 0");
	ASSERT_NOTEQUALS( 0, short1.compare( long2 ), "short1.compare( long2) == 0");
	
	ASSERT_EQUALS( 0, long1.compare( long2 ), "long1.compare( long2 ) != 0");
	ASSERT_NOTEQUALS( 0, long1.compare( empty1 ), "long1.compare( empty1 ) == 0");
	ASSERT_NOTEQUALS( 0, long1.compare( empty2), "long1.compare( empty2) == 0");
	ASSERT_NOTEQUALS( 0, long1.compare( short1 ), "long1.compare( short1) == 0");
	ASSERT_NOTEQUALS( 0, long1.compare( short2 ), "long1.compare( short2) == 0");

	END_TEST_METHOD
}
Exemple #7
0
int main()
{
  checkDate(0, 3, 14);          // invalid year
  checkDate(1997, 0, 12);       // invalid month
  checkDate(1998, 13, 1);       // invalid month
  checkDate(97, 1, 12);         // invalid year
  checkDate(1999, 2, 29);       // invalid day
  checkDate(1900, 2, 29);       // invalid day

  Date empty(0, 0, 0);
  cout <<"empty: \"" <<empty.ToString() <<"\"\n";
  Date empty2(ChrString(""));
  cout <<"empty2: \"" <<empty2.ToString() <<"\"\n";

  Date d1 = ChrString("20000101");
  Date d2(2000, 3, 1);
  cout <<"Day of week for d1:" <<d1.ToString() <<" == "
       <<DayText[d1.DayOfWeek()] <<endl;
  cout <<"Day of week for d2:" <<d2.ToString() <<" == "
       <<DayText[d2.DayOfWeek()] <<endl;

  Date p1(1996, 2, 29);
  Date p2("20000229");

  cout <<"p1 == " <<p1.ToString() <<endl;
  cout <<"p2 == " <<p2.ToString() <<endl;

  DateStuff::Duration d = p1.AgeBetween(p2);
  cout <<"Duration between p1 and p2: "
       <<d._Year <<" years, "
       <<d._Month <<" months, "
       <<d._Day <<" days\n";

  DateStuff::Duration dd = p1.AgeBetween(d2);
  cout <<"Duration between p1 and d2 (20000301): "
       <<dd._Year <<" years, "
       <<dd._Month <<" months, "
       <<dd._Day <<" days\n";

  if (p1 < p2)
  {
    p1.AddDays(d._Day);
    p1.AddMonths(d._Month);
    p1.AddYears(d._Year);
  }
  else if (p1 > p2)
  {
    p2.AddDays(d._Day);
    p2.AddMonths(d._Month);
    p2.AddYears(d._Year);
  }

  cout <<"p1 == p2 (after adding Duration(p1,p2)): "
       <<((p1 == p2) ? "Yes":"No") <<endl;

  FullDate today;
  Date f(today);
  cout <<"Today: " <<f.ToString() <<endl;
  f.AddWeekDays(2);
  cout <<" +2 weekdays: " <<f.ToString() <<endl;
  f.AddWeekDays(10);
  cout <<" +10 weekdays: " <<f.ToString() <<endl;
  f.AddWeekDays(30);
  cout <<" +30 weekdays: " <<f.ToString() <<endl;
  f.SubtractWeekDays(30);
  cout <<" -30 weekdays: " <<f.ToString() <<endl;
  f.SubtractWeekDays(10);
  cout <<" -10 weekdays: " <<f.ToString() <<endl;
  f.SubtractWeekDays(2);
  cout <<" -2 weekdays: " <<f.ToString() <<endl;

  cout <<"WeekdaysBetween 12/11/96 and 12/13/96: "
       <<Date(1996, 12, 11).WeekDaysBetween(Date(1996, 12, 13))
       <<endl;
  cout <<"WeekdaysBetween 12/13/96 and 12/27/96: "
       <<Date(1996, 12, 13).WeekDaysBetween(Date(1996, 12, 27))
       <<endl;
  cout <<"WeekdaysBetween 12/27/96 and 2/7/97: "
       <<Date(1996, 12, 27).WeekDaysBetween(Date(1997, 2, 7))
       <<endl;

  FullDate f1(d1), f2(d2);
  DateStuff::Duration f12 = f2 - f1;
  cout <<"d1 - d1 == "
       <<f12._Year <<" years, "
       <<f12._Month <<" months, "
       <<f12._Day <<" days\n";
}