Пример #1
0
static void TestBasicSort()
{
    // This just tests the insertion sort and heap sort functions; there's
    // no point running introsort on this small a dataset, it'll just use
    // insertion sort on it anyway.
    sInt x[nTestInts];

    // test plain direct insertion sort
    InitTest(x);
    sInsertionSort(sAll(x));
    VerifySorted(x,nTestInts);

    // test insertion sort with predicate (and reverse order)
    InitTest(x);
    sInsertionSort(sAll(x),sCmpGreater<sInt>());
    VerifyRevSorted(x,nTestInts);

    // test heapsort with direct compare
    InitTest(x);
    sHeapSort(sAll(x));
    VerifySorted(x,nTestInts);

    // test heapsort with predicate (and reverse order)
    InitTest(x);
    sHeapSort(sAll(x),sCmpGreater<sInt>());
    VerifyRevSorted(x,nTestInts);
}
Пример #2
0
int main(void)
{
    nsCOMPtr<nsIServiceManager> servMan;
    NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
    nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
    NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
    registrar->AutoRegister(nsnull);
  
#if defined(XP_WIN) || defined(XP_OS2)
    InitTest("c:\\temp\\", "sub1/sub2/"); // expect failure
    InitTest("d:\\temp\\", "sub1\\sub2\\"); // expect failure

    CreationTest("c:\\temp\\", "file.txt", nsIFile::NORMAL_FILE_TYPE, 0644);
    DeletionTest("c:\\temp\\", "file.txt", PR_FALSE);

    MoveTest("c:\\newtemp\\", "d:");

    CreationTest("c:\\temp\\", "mumble\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\", nsIFile::DIRECTORY_TYPE, 0644);
    DeletionTest("c:\\temp\\", "mumble", PR_TRUE);

    CreateUniqueTest("c:\\temp\\", "foo", nsIFile::NORMAL_FILE_TYPE, 0644);
    CreateUniqueTest("c:\\temp\\", "foo", nsIFile::NORMAL_FILE_TYPE, 0644);
    CreateUniqueTest("c:\\temp\\", "bar.xx", nsIFile::DIRECTORY_TYPE, 0644);
    CreateUniqueTest("c:\\temp\\", "bar.xx", nsIFile::DIRECTORY_TYPE, 0644);
    DeletionTest("c:\\temp\\", "foo", PR_TRUE);
    DeletionTest("c:\\temp\\", "foo-1", PR_TRUE);
    DeletionTest("c:\\temp\\", "bar.xx", PR_TRUE);
    DeletionTest("c:\\temp\\", "bar-1.xx", PR_TRUE);

#else
#ifdef XP_UNIX
    InitTest("/tmp/", "sub1/sub2/"); // expect failure
    
    CreationTest("/tmp", "file.txt", nsIFile::NORMAL_FILE_TYPE, 0644);
    DeletionTest("/tmp/", "file.txt", PR_FALSE);
    
    CreationTest("/tmp", "mumble/a/b/c/d/e/f/g/h/i/j/k/", nsIFile::DIRECTORY_TYPE, 0644);
    DeletionTest("/tmp", "mumble", PR_TRUE);

    CreationTest("/tmp", "file", nsIFile::NORMAL_FILE_TYPE, 0644);
    CopyTest("/tmp/file", "/tmp/newDir");
    MoveTest("/tmp/file", "/tmp/newDir/anotherNewDir");
    DeletionTest("/tmp", "newDir", PR_TRUE);

#endif /* XP_UNIX */
#endif /* XP_WIN || XP_OS2 */
    return 0;
}
Пример #3
0
void CnsIEditSession::OnStartTests(UINT nMenuID)
{
	switch(nMenuID)
	{
		case ID_INTERFACES_NSIEDITINGSESSION_RUNALLTESTS :
			RunAllTests();
			break;
		case ID_INTERFACES_NSIEDITINGSESSION_INIT :
			InitTest(2);
			break;
		case ID_INTERFACES_NSIEDITINGSESSION_MAKEWINDOWEDITABLE :
			MakeWinEditTest(PR_FALSE, 2);
			break;
		case ID_INTERFACES_NSIEDITINGSESSION_WINDOWISEDITABLE  :
			WinIsEditTest(PR_TRUE, 2);
			break;
		case ID_INTERFACES_NSIEDITINGSESSION_GETEDITORFORWINDOW :
			GetEditorWinTest(2);
			break;
		case ID_INTERFACES_NSIEDITINGSESSION_SETUPEDITORONWINDOW :
			SetEditorWinTest(2);
			break;
		case ID_INTERFACES_NSIEDITINGSESSION_TEARDOWNEDITORONWINDOW :
			TearEditorWinTest(2);
			break;
	}
}
Пример #4
0
static int AssocMgrModulesLoaded(WPARAM wParam,LPARAM lParam)
{
	UNREFERENCED_PARAMETER(wParam);
	UNREFERENCED_PARAMETER(lParam);
	InitTest();
	return 0;
}
Пример #5
0
void CnsIEditSession::RunAllTests()
{
	InitTest(1);
	MakeWinEditTest(PR_FALSE, 1);
	WinIsEditTest(PR_TRUE, 1);
	GetEditorWinTest(1);
//	SetEditorWinTest(1);		 
	TearEditorWinTest(1);
}
Пример #6
0
void csp::OpTestSuite_RunAll::InitTestSuite( lua::LuaStack& stack, InitError& initError, const char* suiteName, lua::LuaStackValue& suiteEnv )
{
    for ( lua::LuaStackTableIterator it( suiteEnv ); it; it.Next() )
    {
        lua::LuaStackValue name = it.Key();
        lua::LuaStackValue value = it.Value();

        if ( name.IsString() && value.IsFunction() )
            InitTest( stack, initError, suiteName, name.GetString(), value );
    }

    return InitTestSuiteEnv( stack, suiteName, suiteEnv, suiteEnv );
}
Пример #7
0
int EXTAPI Init(int argc, char** argv)
{
#if defined(GINKGO_PRO)
        bool unitTest = false;

        for( int i = 1; i < argc; i++ ) {
                if (std::strcmp(argv[i], "-unittest") == 0) {
                        unitTest = true;
                }
        }

        for( int i = 0; i < argc; i++) {
                GlobalFree(argv[i]);
        }
        GlobalFree(argv);

        if (unitTest) {
                return InitTest();
        }
#endif
        std::cout << "calling InitWX(argc, argv);\n";
        return InitWX(argc, argv);
}
Пример #8
0
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int iShowCmd)
{
	HWND		hwnd;
	MSG			msg;
	WNDCLASSEX	wndclass;

	hInstance = hInst;

	InitTest();

	//Window class for the main application parent window
	wndclass.cbSize			= sizeof(wndclass);
	wndclass.style			= 0;
	wndclass.lpfnWndProc	= WndProc;
	wndclass.cbClsExtra		= 0;
	wndclass.cbWndExtra		= 0;
	wndclass.hInstance		= hInstance;
	wndclass.hIcon			= LoadIcon(0, MAKEINTRESOURCE(IDI_APPLICATION));
	wndclass.hCursor		= LoadCursor (NULL, IDC_ARROW);
	wndclass.hbrBackground	= (HBRUSH)0;
	wndclass.lpszMenuName	= MAKEINTRESOURCE(IDR_MENU1);
	wndclass.lpszClassName	= szAppName;
	wndclass.hIconSm		= LoadIcon (NULL, IDI_APPLICATION);

	RegisterClassEx(&wndclass);

	//Window class for the child window 
	wndclass.cbSize			= sizeof(wndclass);
	wndclass.style			= 0;
	wndclass.lpfnWndProc	= ChildWndProc;
	wndclass.cbClsExtra		= 0;
	wndclass.cbWndExtra		= 0;
	wndclass.hInstance		= hInst;
	wndclass.hIcon			= 0;
	wndclass.hCursor		= LoadCursor (NULL, IDC_ARROW);
	wndclass.hbrBackground	= (HBRUSH)(COLOR_WINDOW + 1);
	wndclass.lpszMenuName	= 0;
	wndclass.lpszClassName	= szChildClass;
	wndclass.hIconSm		= 0;

	RegisterClassEx(&wndclass);

	hwnd = CreateWindowEx(0,
				szAppName,				// window class name
				szAppName,				// window caption
				WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
				CW_USEDEFAULT,			// initial x position
				CW_USEDEFAULT,			// initial y position
				350,					// initial x size
				200,					// initial y size
				NULL,					// parent window handle
				NULL,					// use window class menu
				hInstance,				// program instance handle
				NULL);					// creation parameters

	hwndMain = hwnd;

	ShowWindow(hwnd, iShowCmd);

	while(GetMessage(&msg, NULL,0,0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return 0;
}
Пример #9
0
int
main(int argc, char *argv[])
{
  const int winWidth = 800, winHeight = 600;
  Display *x_dpy;
  Window win;
  EGLSurface egl_surf;
  EGLContext egl_ctx;
  EGLDisplay egl_dpy;
  char *dpyName = NULL;
  GLboolean printInfo = GL_FALSE;
  EGLint egl_major, egl_minor;
  const char *s;


  if (!InitTest(argc, argv)) {
    return -1;
  }

  x_dpy = XOpenDisplay(dpyName);
  if (!x_dpy) {
    printf("Error: couldn't open display %s\n",
           dpyName ? dpyName : getenv("DISPLAY"));
    return -1;
  }

  egl_dpy = eglGetDisplay(x_dpy);
  if (!egl_dpy) {
    printf("Error: eglGetDisplay() failed\n");
    return -1;
  }

  if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
    printf("Error: eglInitialize() failed\n");
    return -1;
  }

  s = eglQueryString(egl_dpy, EGL_VERSION);
  printf("EGL_VERSION = %s\n", s);

  s = eglQueryString(egl_dpy, EGL_VENDOR);
  printf("EGL_VENDOR = %s\n", s);

  s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
  printf("EGL_EXTENSIONS = %s\n", s);

  s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
  printf("EGL_CLIENT_APIS = %s\n", s);

  make_x_window(x_dpy, egl_dpy,
               "OpenGL ES 2.x tri", 0, 0, winWidth, winHeight,
               &win, &egl_ctx, &egl_surf);

  XMapWindow(x_dpy, win);
  if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
    printf("Error: eglMakeCurrent() failed\n");
    return -1;
  }

  if (printInfo) {
    printf("GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
    printf("GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
    printf("GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
    printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
  }


  InitRendering();

  LoadData(testHelper->app()->defaultBuiltinDatasetIndex());

  // render once
  testHelper->app()->resizeView(winWidth, winHeight);
  testHelper->app()->applyBuiltinDatasetCameraParameters(testHelper->app()->defaultBuiltinDatasetIndex());
  testHelper->app()->render();
  eglSwapBuffers(egl_dpy, egl_surf);

  // begin the event loop if not in testing mode
  bool testPassed = true;
  if (!testHelper->isTesting()) {
    event_loop(x_dpy, win, egl_dpy, egl_surf);
  }
  else {
    testPassed = DoTesting();
  }

  FinalizeTest();

  eglDestroyContext(egl_dpy, egl_ctx);
  eglDestroySurface(egl_dpy, egl_surf);
  eglTerminate(egl_dpy);


  XDestroyWindow(x_dpy, win);
  XCloseDisplay(x_dpy);

  return testPassed ? 0 : 1;
}
Пример #10
0
int
main (int argc, char *argv[])
{
	SDLMdeScreen mdescreen;
	SDL_Surface *screen;
	
	bool running;
	if (SDL_Init(SDL_INIT_VIDEO) == -1)
	{
		fprintf(stderr, "Unable to initialize SDL: %s.\n", SDL_GetError());
		exit(-1);
	}
    screen = SDL_SetVideoMode(IMAGE_WIDTH, IMAGE_HEIGHT, 32, SDL_SWSURFACE);
    if (screen == NULL)
	{
        fprintf(stderr, "Couldn't set %dx%dx32 video mode: %s\n",
                        IMAGE_WIDTH, IMAGE_HEIGHT, SDL_GetError());
        exit(1);
    }
	// keep the surface locked until we need to update it..
	if (SDL_MUSTLOCK(screen))
		SDL_LockSurface(screen);

	

	mdescreen.sdl_screen = screen;

	InitTest(&mdescreen);

	// poll event and send the events to the gogi api
	running = true;
	while (running)
	{
		SDL_Event event;
		while (SDL_PollEvent(&event))
		{
			switch (event.type)
			{
			case SDL_MOUSEMOTION:
				mdescreen.TrigMouseMove((int)event.motion.x, (int)event.motion.y);
				break;
			case SDL_MOUSEBUTTONUP:
				// TODO: check event.button.state (pressed/released)
				switch (event.button.button)
				{
				case SDL_BUTTON_LEFT:
					mdescreen.TrigMouseUp((int)event.button.x, (int)event.button.y, 1);
					break;
				case SDL_BUTTON_RIGHT:
					mdescreen.TrigMouseUp((int)event.button.x, (int)event.button.y, 2);
					break;
				case SDL_BUTTON_MIDDLE:
					mdescreen.TrigMouseUp((int)event.button.x, (int)event.button.y, 3);
					break;
				case SDL_BUTTON_WHEELUP:
					mdescreen.TrigMouseWheel((int)event.button.x, (int)event.button.y, -1, true, SHIFTKEY_NONE);
					break;
				case SDL_BUTTON_WHEELDOWN:
					mdescreen.TrigMouseWheel((int)event.button.x, (int)event.button.y, 1, true, SHIFTKEY_NONE);
					break;
				default:
					break;
				}
				break;
			case SDL_MOUSEBUTTONDOWN:
				switch (event.button.button)
				{
				case SDL_BUTTON_LEFT:
					mdescreen.TrigMouseDown((int)event.button.x, (int)event.button.y, 1, 1);
					break;
				case SDL_BUTTON_RIGHT:
					mdescreen.TrigMouseDown((int)event.button.x, (int)event.button.y, 2, 1);
					break;
				case SDL_BUTTON_MIDDLE:
					mdescreen.TrigMouseDown((int)event.button.x, (int)event.button.y, 3, 1);
					break;
				default:
					break;
				}
				break;
			case SDL_QUIT:
				running = false;
				break;
			default:
				break;
			}
		}
		PulseTest(&mdescreen);
		mdescreen.Validate(true);
		SDL_Delay(10);
	}

  

	ShutdownTest();
	
	if (SDL_MUSTLOCK(screen))
		SDL_UnlockSurface(screen);
	// shutdown sdl
	SDL_Quit();
	
	return 0;
}