示例#1
0
void test_operator_index() {
	cout << "Testing operator [] and reverse()" << endl;
	cout << "--------------------------------------------" << endl;
	String s = "hello";
	String s2 = "good";
	String s3("helloworld");
	String s4("class");

	cout << "operator []: s[1] from \"hello\" = " << s[1] << endl;
	cout << "operator []: s[4] from \"hello\" = " << s[4] << endl;
	
	cout << "Testing reverse(): \"helloworld\" = " << s3.reverse() << endl;
	cout << "Testing reverse(): \"class\" = " << s4.reverse() << endl;
	cout << "--------------------------------------------" << endl << endl;
}
示例#2
0
void constuctors()
{
/*       MemStat memStat("constructors");    */
    String s1, s2((Size_T)(55)), s3("12345", 4), s4("12345"), s5('x');
    String s6('x', 27);

    cout << "constructors" << endl;
    s2 = "123";
    assert(s1.length() == 0);
    assert(s2.length() == 3);
    assert(s2.reserve() > s2.length());
    assert(s3.length() == 4);
    assert(s4.length() == 5);
    assert(s5.length() == 1  && s5.getAt(0) == 'x');
    assert(s6.length() == 27 && s6.getAt(26) == 'x');
}
示例#3
0
void StringTest::testCStr()
{
    cxxtools::String s1(L"abc");
    CXXTOOLS_UNIT_ASSERT(s1.c_str()[0] == 'a' && s1.c_str()[1] == 'b' && s1.c_str()[2] == 'c' && s1.c_str()[3] == '\0');

    cxxtools::String s2;
    CXXTOOLS_UNIT_ASSERT(s2.c_str()[0] == '\0');

    cxxtools::Char abc[] = { 'a', 'b', 'c', '\0' };
    cxxtools::String s3(abc);
    CXXTOOLS_UNIT_ASSERT(s3.c_str()[0] == 'a' && s3.c_str()[1] == 'b' && s3.c_str()[2] == 'c' && s3.c_str()[3] == '\0');

    cxxtools::Char zero[] = { '\0' };
    cxxtools::String s4(zero);
    CXXTOOLS_UNIT_ASSERT(s4.c_str()[0] == '\0');
}
示例#4
0
    ///////////////////////////////////////////////////////// Test /////
    // test the different constructor and the c_str() method.
    void testConstruct() {
        StringBuffer s1;
        CPPUNIT_ASSERT(s1.c_str() == NULL);

        StringBuffer s2("");
        CPPUNIT_ASSERT(strcmp(s2.c_str(), "") == 0);

        StringBuffer s3("test");
        CPPUNIT_ASSERT(strcmp(s3.c_str(), "test") == 0);

        StringBuffer s4("0123456789", 4);
        CPPUNIT_ASSERT(strcmp(s4.c_str(), "0123") == 0);

        StringBuffer copy(s3);
        CPPUNIT_ASSERT(strcmp(copy, s3) == 0);
    }
示例#5
0
int main(int argc, char *argv[])
{
	std::string s1("the"), s2("Her"), s3("in");
	const std::string file("text.txt");;
	TextQuery tq;
	std::ifstream fin(file.c_str());
	tq.read_file(fin);
	Query q = (Query(s1) & Query(s2)) | Query(s3);
	std::set<TextQuery::line_no> set = q.eval(tq);
	typedef std::set<TextQuery::line_no>::iterator iter_stq;
	for( iter_stq iter= set.begin() ; iter != set.end() ; iter++ )
	{
		std::cout << tq.text_line(*iter) << std::endl;
	}
	return 0;
}
TEST(SimpleString, Concatenation)
{
	SimpleString s1("hello!");
	SimpleString s2("goodbye!");
	SimpleString s3("hello!goodbye!");
	SimpleString s4;
	s4 += s1;
	s4 += s2;

	CHECK_EQUAL(s3, s4);

	SimpleString s5("hello!goodbye!hello!goodbye!");
	s4 += s4;

	CHECK_EQUAL(s5, s4);
}
示例#7
0
void GenericRenderer::render(Renderable& buffer, CameraID camera, GPUProgram* program) {

    if(!program) {
        L_ERROR("No shader is bound, so nothing will be rendered");
        return;
    }

    std::size_t index_count = buffer.index_data().count();
    if(!index_count) {
        return;
    }

    GLStateStash s2(GL_ELEMENT_ARRAY_BUFFER_BINDING);
    GLStateStash s3(GL_ARRAY_BUFFER_BINDING);

    buffer._update_vertex_array_object();
    buffer._bind_vertex_array_object();

    //Attributes don't change per-iteration of a pass
    set_auto_attributes_on_shader(buffer);
    set_auto_uniforms_on_shader(*program, camera, buffer);

    //Render the mesh, once for each iteration of the pass
    switch(buffer.arrangement()) {
        case MESH_ARRANGEMENT_POINTS:
            GLCheck(glDrawElements, GL_POINTS, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
        break;
        case MESH_ARRANGEMENT_LINES:
            GLCheck(glDrawElements, GL_LINES, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
        break;
        case MESH_ARRANGEMENT_LINE_STRIP:
            GLCheck(glDrawElements, GL_LINE_STRIP, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
        break;
        case MESH_ARRANGEMENT_TRIANGLES:
            GLCheck(glDrawElements, GL_TRIANGLES, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
        break;
        case MESH_ARRANGEMENT_TRIANGLE_STRIP:
            GLCheck(glDrawElements, GL_TRIANGLE_STRIP, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
        break;
        case MESH_ARRANGEMENT_TRIANGLE_FAN:
            GLCheck(glDrawElements, GL_TRIANGLE_FAN, index_count, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
        break;
        default:
            throw NotImplementedError(__FILE__, __LINE__);
    }

}
示例#8
0
int main(int argc, char * argv[]){
	Triangle t1(3,3,3,1,1);
	Square s1(6,2,2);
	Circle c1(7,3,3);
	Sphere sp1(10,4,4,4);
	Cube cu1(10,5,5,5);
	Tetrahedron te1(5,6,7,8,9,10,6,6,6);
	Cube cu2(5,7,7,7);
	Square s2(16,8,8);
	Circle c2(1,9,9);
	Circle c3(55,10,10);
	Square s3(3,11,11);
	Tetrahedron te2(3,3,3,3,3,3,12,12,12);
	
	Shape * arr = new Shape[12];
	arr[0] = t1;
	arr[1] = s1;
	arr[2] = c1;
	arr[3] = sp1;
	arr[4] = cu1;
	arr[5] = te1;
	arr[6] = cu2;
	arr[7] = s2;
	arr[8] = c2;
	arr[9] = c3;
	arr[10] = s3;
	arr[11] = te2;

	for(int i = 0; i < 11; ++i){
		cout << endl;
		if(arr[i].getT() == 2){
			cout << "2-D Shape Found" << endl;
			cout << "Points are: (" << arr[i].getX() << ", " << arr[i].getY() << ")" << endl;
			cout << "Area is: " << arr[i].getArea() << endl;
		}
		else{
			cout << "3-D Shape" << endl;
			cout << "At Pt: (" << arr[i].getX() << ", " << arr[i].getY() << ", " << arr[i].getZ() <<")" << endl;
			cout << "Surface Area is: " << arr[i].getSurface() << endl;
			cout << "Volume is: " << arr[i].getVolume() << endl;
		}
	}

	delete[] arr;

	return 0;
}
示例#9
0
void UnicodeTestCase::ConstructorsWithConversion()
{
    // the string "Déjà" in UTF-8 and wchar_t:
    const unsigned char utf8Buf[] = {0x44,0xC3,0xA9,0x6A,0xC3,0xA0,0};
    const unsigned char utf8subBuf[] = {0x44,0xC3,0xA9,0x6A,0}; // just "Déj"
    const char *utf8 = (char *)utf8Buf;
    const char *utf8sub = (char *)utf8subBuf;

    wxString s1(utf8, wxConvUTF8);

#if wxUSE_UNICODE
    const wchar_t wchar[] = {0x44,0xE9,0x6A,0xE0,0};
    CPPUNIT_ASSERT_EQUAL( wchar, s1 );

    wxString s2(wchar);
    CPPUNIT_ASSERT_EQUAL( wchar, s2 );
    CPPUNIT_ASSERT_EQUAL( wxString::FromUTF8(utf8), s2 );
#else
    CPPUNIT_ASSERT_EQUAL( utf8, s1 );
#endif

    wxString sub(utf8sub, wxConvUTF8); // "Dej" substring
    wxString s3(utf8, wxConvUTF8, 4);
    CPPUNIT_ASSERT_EQUAL( sub, s3 );

#if wxUSE_UNICODE
    wxString s4(wchar, wxConvUTF8, 3);
    CPPUNIT_ASSERT_EQUAL( sub, s4 );

    // conversion should stop with failure at pos 35
    wxString s("\t[pl]open.format.Sformatuj dyskietk\xea=gfloppy %f", wxConvUTF8);
    CPPUNIT_ASSERT( s.empty() );
#endif // wxUSE_UNICODE


    // test using Unicode strings together with char* strings (this must work
    // in ANSI mode as well, of course):
    wxString s5("ascii");
    CPPUNIT_ASSERT_EQUAL( "ascii", s5 );

    s5 += " value";

    CPPUNIT_ASSERT( strcmp(s5.mb_str(), "ascii value") == 0 );
    CPPUNIT_ASSERT_EQUAL( "ascii value", s5 );
    CPPUNIT_ASSERT( s5 != "SomethingElse" );
}
示例#10
0
文件: main.cpp 项目: CCJY/coliru
int main()
{
    while (true)
    {
        cout
    }
    D d1 = 1;
    S s2("2");
    try {
         S s3("not a number");
    } catch(const std::exception&) {}
    std::cout << s2.getData() << '\n';
 
   D d2(3, 4);
   d2 = d1; // OK: assignment to lvalue
//   D(5) = d1; // ERROR: no suitable overload of operator=
}
示例#11
0
void turnLeft() {
	// Take a left turn !!
	int t=0, s=0;
	//mvfwdpulse();
	while((s1()==BLACK) | (s5()==BLACK))
		fwd();

	while(t==0 |s==0 | s3()==WHITE) {
		left();
		if(s5()==BLACK) t=1;
		if(s1()==BLACK) s=1;
	}
	fwd();
	curHead+=1;
	curHead%=4;
	// Left turn complete
}
示例#12
0
//--------------------------------------------------------------------//
void turnRight() {
	// Take a right turn !!
	int t=0,s=0;
	//mvfwdpulse();
	while((s1()==BLACK) | (s5()==BLACK))
		fwd();
	
	while((t==0 | s==0) | s3()==WHITE) {
		right();
		if(s1()==BLACK) t=1;
		if(s5()==BLACK) s=1;
	}
	fwd();
	curHead+=3;
	curHead%=4;
	// Right turn complete
}
示例#13
0
void Test_M2MString::test_compare()
{
    String s("name");
    String s1("yeb");
    String s2("name");
    String s3("nam");

    CHECK(s.compare(1,5, s1) < 0);
    CHECK(s1.compare(0,5, s2) > 0);
    CHECK(s.compare(0,4, s2) == 0);
    CHECK(s.compare(0,4, s3) > 0);

    CHECK(s.compare(1,5, "yeb") < 0);
    CHECK(s1.compare(0,5, "name") > 0);
    CHECK(s.compare(0,4, "name") == 0);
    CHECK(s.compare(0,4, "nam") > 0);
}
示例#14
0
int
ACE_TMAIN (int, ACE_TCHAR *[])
{
  ACE_CString s1 ("hello");
  ACE_CString s2 ("world");
  ACE_CString s3 ("el");
  ACE_NS_WString s4 ("hello");
  ACE_NS_WString s5 ("world");
  ACE_NS_WString s6 ("el");

  ACE_ASSERT (s1 != s2);
  ACE_ASSERT (s1.strstr (s2) == ACE_CString::npos);
  ACE_ASSERT (s1.strstr (s2) == ACE_CString::npos);
  ACE_ASSERT (s1.strstr (s3));
  ACE_ASSERT (s4.strstr (s5) == ACE_NS_WString::npos);
  ACE_ASSERT (s5.strstr (s6));
  return 0;
}
示例#15
0
void replace()
{
/*       MemStat memStat("replace");    */
    String s1("1234", 5), s2("abcd");
    String s3("1235", 4), s4("1232");
    String s5, s6;

    cout << "replace" << endl;
    assert(s1.length() == 5);
    s6 = s1;
    assert(s1.length() == 5);
    assert(s6.length() == 5);

    s1.replace(1, 2, s2);
    assert(s1 == String("1abcd4", 7));
    s2.replace(1,2, s2);
    assert(s2 == String("aabcdd", 6));
}
示例#16
0
文件: main.cpp 项目: Chingliu/winx
void testWrite()
{
	NS_STDEXT::WinRegWriteKey(HKEY_CURRENT_USER, WINX_TEST_KEY_)
		.putDWord(WINX_TEXT("dword"), 123);

	NS_STDEXT::WinRegWriteKey(HKEY_CURRENT_USER, WINX_TEST_KEY_)
		.putGuid(WINX_TEXT("guid"), IID_IClassFactory);

	NS_STDEXT::WinRegWriteKey(HKEY_CURRENT_USER, WINX_TEST_KEY_)
		.putString(WINX_TEXT("string"), WINX_TEXT("abc"));

	NS_STDEXT::WinRegWriteKey(HKEY_CURRENT_USER, WINX_TEST_KEY_)
		.putString(WINX_TEXT("string2"), std::vector<TCHAR>(257, '!'));

	std::basic_string<TCHAR> s3(WINX_TEXT("string3"));
	NS_STDEXT::WinRegWriteKey(HKEY_CURRENT_USER, WINX_TEST_KEY_)
		.putString(WINX_TEXT("string3"), s3);
}
示例#17
0
TEST( CFPP_WriteStream, OperatorAssignAutoPointer )
{
    CF::WriteStream s1;
    CF::WriteStream s2( CF::URL( "file:///etc/hosts" ) );
    CF::WriteStream s3( CF::URL( "file:///etc/hosts" ) );
    
    ASSERT_FALSE( s1.IsValid() );
    ASSERT_TRUE(  s2.IsValid() );
    ASSERT_TRUE(  s3.IsValid() );
    
    s1 = CF::AutoPointer( CFWriteStreamCreateWithFile( NULL, CF::URL( "file:///etc/hosts" ) ) );
    s2 = CF::AutoPointer( CFUUIDCreate( NULL ) );
    s3 = CF::AutoPointer( NULL );
    
    ASSERT_TRUE(  s1.IsValid() );
    ASSERT_FALSE( s2.IsValid() );
    ASSERT_FALSE( s3.IsValid() );
}
示例#18
0
TEST( CFPP_WriteStream, Open )
{
    CF::WriteStream s1;
    CF::WriteStream s2( std::string( "/etc/hosts" ) );
    CF::WriteStream s3( std::string( "/tmp/com.xs-labs.cfpp" ) );
    
    ASSERT_FALSE( s1.Open() );
    ASSERT_FALSE( s2.Open() );
    ASSERT_TRUE(  s3.Open() );
    
    s1.Close();
    s2.Close();
    s3.Close();
    
    ASSERT_FALSE( s1.Open() );
    ASSERT_FALSE( s2.Open() );
    ASSERT_FALSE( s3.Open() );
}
示例#19
0
TEST( CFPP_WriteStream, Close )
{
    CF::WriteStream s1;
    CF::WriteStream s2( "/etc/hosts" );
    CF::WriteStream s3( "/tmp/com.xs-labs.cfpp" );
    
    s1.Open();
    s2.Open();
    s3.Open();
    
    ASSERT_NO_FATAL_FAILURE( s1.Close() );
    ASSERT_NO_FATAL_FAILURE( s2.Close() );
    ASSERT_NO_FATAL_FAILURE( s3.Close() );
    
    ASSERT_NO_THROW( s1.Close() );
    ASSERT_NO_THROW( s2.Close() );
    ASSERT_NO_THROW( s3.Close() );
}
示例#20
0
// Don't forget you will need to edit/change this to make it look
// like our lab sheet for this week!
int main()
{
   String s1("Test String1");
   String s2("Test String 2");
   String s3(s1);
   s1.Display("HELP");
   s2.Display();
   s3.Display();
      
// Helping you out here :-)  DON'T FORGET TO ADD THE REST FROM THE LAB AND REMOVE THESE //

// if(!s3)
// cout << "s3 is null\n";
// s1 = "";
//if(!s1)
// cout << "s1 is null\n;
   return 0;
}
示例#21
0
文件: Student.c 项目: seyko2/cfront-3
main()
{
    Student s1("George","A");
    Student s2("Arthur","D");
    Student s3("Chester","C");
    Student s4("Willy","B");
 
    List<Student> Class(s1,s2,s3,s4);
    // Class.print(cout) << "\n";
    cout << Class << "\n";
    Class.sort(name_compare);
    // Class.print(cout) << "\n";
    cout << Class << "\n";
    Class.sort(grade_compare);
    // Class.print(cout) << "\n";
    cout << Class << "\n";
    return 0;
}
示例#22
0
TEST( CFPP_WriteStream, WriteAll_BytePtr_CFIndex )
{
    CF::WriteStream s1;
    CF::WriteStream s2( "/etc/hosts" );
    CF::WriteStream s3( "/tmp/com.xs-labs.cfpp" );
    CF::Data::Byte  buf[ 4 ];
    
    buf[ 0 ] = 0xDE;
    buf[ 1 ] = 0xAD;
    buf[ 2 ] = 0xBE;
    buf[ 3 ] = 0xEF;
    
    ASSERT_FALSE( s1.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_FALSE( s2.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_FALSE( s3.WriteAll( buf, sizeof( buf ) ) );
    
    s1.Open();
    s2.Open();
    s3.Open();
    
    ASSERT_FALSE( s1.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_FALSE( s2.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_TRUE(  s3.WriteAll( buf, sizeof( buf ) ) );
    
    ASSERT_NO_FATAL_FAILURE( s1.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_NO_FATAL_FAILURE( s2.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_NO_FATAL_FAILURE( s3.WriteAll( NULL, sizeof( buf ) ) );
    
    ASSERT_NO_THROW( s1.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_NO_THROW( s2.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_NO_THROW( s3.WriteAll( NULL, sizeof( buf ) ) );
    
    ASSERT_FALSE( s1.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_FALSE( s2.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_FALSE( s3.WriteAll( NULL, sizeof( buf ) ) );
    
    s1.Close();
    s2.Close();
    s3.Close();
    
    ASSERT_FALSE( s1.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_FALSE( s2.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_FALSE( s3.WriteAll( buf, sizeof( buf ) ) );
}
/**
 * Simple program that starts our raytracer
 */
int main(int argc, char *argv[]) {
	try {
		RayTracer* rt;
		Timer t;
		rt = new RayTracer(800, 600);
		
		std::shared_ptr<SceneObjectEffect> color(new ColorEffect(glm::vec3(0.0, 1.0, 0.0)));
		std::shared_ptr<SceneObjectEffect> phong(new PhongEffect(glm::vec3(0.0, 0.0, 10.0)));
		std::shared_ptr<SceneObjectEffect> steel(new SteelEffect());
		std::shared_ptr<SceneObjectEffect> fresnel(new FresnelEffect());
		
		std::shared_ptr<SceneObject> s1(new Sphere(glm::vec3(-3.0f, 0.0f, 6.0f), 2.0f, steel));
		rt->addSceneObject(s1);
		std::shared_ptr<SceneObject> s2(new Sphere(glm::vec3(3.0f, 0.0f, 3.0f), 2.0f, fresnel));
		rt->addSceneObject(s2);
		std::shared_ptr<SceneObject> s3(new Sphere(glm::vec3(0.0f, 3.0f, 9.0f), 2.0f, steel));
		rt->addSceneObject(s3);


		std::string path = "cubemaps/SaintLazarusChurch3/";
		std::shared_ptr<SceneObject> cubeMap(new CubeMap(path + "posx.jpg", path + "negx.jpg",
			path + "posy.jpg", path + "negy.jpg",
			path + "posz.jpg", path + "negz.jpg"));
		rt->addSceneObject(cubeMap);


		std::shared_ptr<SceneObject> triangle(new Triangle(glm::vec3(0.0f, 2.0f, -1.0f), 
			glm::vec3(-2.0f, -2.0f, -1.0f), glm::vec3(2.0f, -2.0f, 0.0f),  steel));
		rt->addSceneObject(triangle);
				
		t.restart();
		rt->render();
		double elapsed = t.elapsed();
		std::cout << "Computed in " << elapsed << " seconds" <<  std::endl;
		rt->save("test", "bmp"); //We want to write out bmp's to get proper bit-maps (jpeg encoding is lossy)

		delete rt;
	} catch (std::exception &e) {
		std::string err = e.what();
		std::cout << err.c_str() << std::endl;
		return -1;
	}
	return 0;
}
示例#24
0
void test_session_string(const char* addr)
{
	acl::session_string s1;
	s1.copy(addr, strlen(addr));
	s1.todo_ = acl::TODO_DEL;

	printf("s1: addr: %s, todo: %d\r\n", s1.c_str(), s1.todo_);

	acl::session_string s2 = s1;
	printf("structor copy --> s2: addr: %s, todo: %d\r\n", s2.c_str(), s2.todo_);

	s1.todo_ = acl::TODO_NUL;
	s2 = s1;
	printf("assign copy --> s2: addr: %s, todo: %d\r\n", s2.c_str(), s2.todo_);

	s2.todo_ = acl::TODO_SET;
	acl::session_string s3(s2);
	printf("structor copy --> s3: addr: %s, todo: %d\r\n", s3.c_str(), s3.todo_);
}
示例#25
0
int main ()
{
  // Construct the arrangement containing two intersecting triangles.
  Arrangement_2          arr;
  Face_index_observer    obs (arr);

  Segment_2      s1 (Point_2(4, 1), Point_2(7, 6));
  Segment_2      s2 (Point_2(1, 6), Point_2(7, 6));
  Segment_2      s3 (Point_2(4, 1), Point_2(1, 6));
  Segment_2      s4 (Point_2(1, 3), Point_2(7, 3));
  Segment_2      s5 (Point_2(1, 3), Point_2(4, 8));
  Segment_2      s6 (Point_2(4, 8), Point_2(7, 3));

  insert_non_intersecting_curve (arr, s1);
  insert_non_intersecting_curve (arr, s2);
  insert_non_intersecting_curve (arr, s3);
  insert (arr, s4);
  insert (arr, s5);
  insert (arr, s6);

  // Go over all arrangement faces and print the index of each face and it
  // outer boundary. The face index is stored in its data field in our case.
  Arrangement_2::Face_const_iterator            fit;
  Arrangement_2::Ccb_halfedge_const_circulator  curr;

  std::cout << arr.number_of_faces() << " faces:" << std::endl;
  for (fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) {
    std::cout << "Face no. " << fit->data() << ": ";
    if (fit->is_unbounded())
      std::cout << "Unbounded." << std::endl;
    else {
      curr = fit->outer_ccb();
      std::cout << curr->source()->point();
      do {
        std::cout << " --> " << curr->target()->point();
        ++curr;
      } while (curr != fit->outer_ccb());
      std::cout << std::endl;
    }
  }

  return 0;
}
示例#26
0
TEST( CFPP_WriteStream, SetProperty )
{
    CF::WriteStream  s1;
    CF::WriteStream  s2( "/etc/hosts" );
    CF::WriteStream  s3( "/tmp/com.xs-labs.cfpp" );
    CF::AutoPointer p1;
    CF::AutoPointer p2;
    CF::AutoPointer p3;
    
    p1 = s1.GetProperty( kCFStreamPropertyFileCurrentOffset );
    p2 = s2.GetProperty( kCFStreamPropertyFileCurrentOffset );
    p3 = s3.GetProperty( kCFStreamPropertyFileCurrentOffset );
    
    ASSERT_FALSE( p1.IsValid() );
    ASSERT_FALSE( p2.IsValid() );
    ASSERT_FALSE( p3.IsValid() );
    
    s1.Open();
    s2.Open();
    s3.Open();
    
    ASSERT_FALSE( s1.SetProperty( kCFStreamPropertyFileCurrentOffset, CF::Number( 42 ) ) );
    ASSERT_TRUE(  s2.SetProperty( kCFStreamPropertyFileCurrentOffset, CF::Number( 42 ) ) );
    ASSERT_TRUE(  s3.SetProperty( kCFStreamPropertyFileCurrentOffset, CF::Number( 42 ) ) );
    
    p1 = s1.GetProperty( kCFStreamPropertyFileCurrentOffset );
    p2 = s2.GetProperty( kCFStreamPropertyFileCurrentOffset );
    p3 = s3.GetProperty( kCFStreamPropertyFileCurrentOffset );
    
    ASSERT_FALSE( p1.IsValid() );
    ASSERT_TRUE(  p2.IsValid() );
    ASSERT_TRUE(  p3.IsValid() );
    
    ASSERT_TRUE( p2.IsNumber() );
    ASSERT_TRUE( p3.IsNumber() );
    
    ASSERT_EQ( p2.As< CF::Number >(), 42 );
    ASSERT_EQ( p3.As< CF::Number >(), 42 );
    
    s1.Close();
    s2.Close();
    s3.Close();
}
示例#27
0
int main ()
{
  // Construct the first arrangement, containing a square-shaped face.
  Arrangement_2          arr1;

  Segment_2      s1 (Point_2(2, 2), Point_2(6, 2));
  Segment_2      s2 (Point_2(6, 2), Point_2(6, 6));
  Segment_2      s3 (Point_2(6, 6), Point_2(2, 6));
  Segment_2      s4 (Point_2(2, 6), Point_2(2, 2));

  insert_non_intersecting_curve (arr1, s1);
  insert_non_intersecting_curve (arr1, s2);
  insert_non_intersecting_curve (arr1, s3);
  insert_non_intersecting_curve (arr1, s4);

  // Construct the second arrangement, containing a rhombus-shaped face.
  Arrangement_2          arr2;

  Segment_2      t1 (Point_2(4, 1), Point_2(7, 4));
  Segment_2      t2 (Point_2(7, 4), Point_2(4, 7));
  Segment_2      t3 (Point_2(4, 7), Point_2(1, 4));
  Segment_2      t4 (Point_2(1, 4), Point_2(4, 1));

  insert_non_intersecting_curve (arr2, t1);
  insert_non_intersecting_curve (arr2, t2);
  insert_non_intersecting_curve (arr2, t3);
  insert_non_intersecting_curve (arr2, t4);

  // Compute the overlay of the two arrangements.
  Arrangement_2          overlay_arr;
  Overlay_traits         overlay_traits;

  overlay (arr1, arr2, overlay_arr, overlay_traits);

  // Print the size of the overlaid arrangement.
  std::cout << "The overlaid arrangement size:" << std::endl
            << "   V = " << overlay_arr.number_of_vertices()
            << ",  E = " << overlay_arr.number_of_edges() 
            << ",  F = " << overlay_arr.number_of_faces() << std::endl;

  return 0;
}
示例#28
0
void ComplexTestSuite::IO()
{
	gsl::complex z1(1,2);
	std::string s1("1 + 2");
	s1 += IMAG_SYMB;
	std::stringstream ss1;
	ss1 << z1;
	CPPUNIT_ASSERT(s1 == ss1.str());
	
	gsl::complex z2(1,-2);
	std::string s2("1 - 2");
	s2 += IMAG_SYMB;
	std::stringstream ss2;
	ss2 << z2;
	CPPUNIT_ASSERT(s2 == ss2.str());
	
	gsl::complex z3(0,2);
	std::string s3("2");
	s3 += IMAG_SYMB;
	std::stringstream ss3;
	ss3 << z3;
	CPPUNIT_ASSERT(s3 == ss3.str());
	
	gsl::complex z4(0,-3);
	std::string s4("-3");
	s4 += IMAG_SYMB;
	std::stringstream ss4;
	ss4 << z4;
	CPPUNIT_ASSERT(s4 == ss4.str());
	
	gsl::complex z5(1,0);
	std::string s5("1");
	std::stringstream ss5;
	ss5 << z5;
	CPPUNIT_ASSERT(s5 == ss5.str());
	
	gsl::complex z6(0,0);
	std::string s6("0");
	std::stringstream ss6;
	ss6 << z6;
	CPPUNIT_ASSERT(s6 == ss6.str());	
}
示例#29
0
int main() {
    Screen s1 ( 4, 4, '*' );
    Screen s2 ( 2, 6, '@' );
    Screen s3 ( 5, 3, '-' );

    const int arrSize = 3;
    Screen *parray = new Screen[ arrSize ];

    parray[0] = s1;
    parray[1] = s2;
    parray[2] = s3;

    ScreenPtr parr( *parray, arrSize );

    for ( int ix = 0; ix < arrSize; ++ix )
        parr++.display();

    delete parray;
    return 0;
}
示例#30
0
  double evaluate(const vectord& x)
  {
    vectord mu1(2), mu2(2), mu3(2);
    matrixd s1(2,2), s2(2,2), s3(2,2);

    mu1 <<= 0,0;
    mu2 <<= 1,1;
    mu3 <<= -4,2;
    
    s1 <<= 1,0, 
      0,1;

    s2 <<= 4,0,
      0,0.6;

    s3 <<= 4,0,
      0,0.6;
  
    return gauss(x,mu1,s1) + gauss(x,mu2,s2) + gauss(x,mu3,s3);
  }