void test(){ testAdd(); testSub(); testMult(); testScale(); testEquals(); testDivision(); testAbsolute(); testArgument(); printf("All passed!\n"); }
void FilesTest::create() { font = new BitmapFont(); batch = new SpriteBatch(); if(Gdx.files->isExternalStorageAvailable()) { message += "External storage available\n"; std::string externalStoragePath; Gdx.files->getExternalStoragePath(externalStoragePath); message += "External storage path: " + externalStoragePath + "\n"; try { FileHandle cube = Gdx.files->internalHandle("data/cube.obj"); std::ifstream in; cube.read(in); try { in.close(); } catch(std::exception e) { } message += "Open internal success\n"; } catch(std::exception e) { message += "Couldn't open internal data/cube.obj\n"; message += e.what(); message += "\n"; } try { FileHandle testFile = Gdx.files->externalHandle("test.txt"); std::ofstream testStream; testFile.write(false, testStream); testStream << "test"; testStream.close(); message += "Write external success\n"; } catch(GdxRuntimeException ex) { message += "Couldn't open externalstorage/test.txt\n"; } catch(std::exception e) { message += "Couldn't write externalstorage/test.txt\n"; } try { FileHandle testFile = Gdx.files->externalHandle("test.txt"); std::ifstream in; testFile.read(in); in.close(); message += "Open external success\n"; } catch(GdxRuntimeException e) { message += "Couldn't open internal externalstorage/test.txt\n"; } FileHandle file = Gdx.files->externalHandle("test.txt"); if(!file.remove()) { message += "Couldn't delete externalstorage/test.txt"; } file = Gdx.files->externalHandle("this/is/a/test"); file.mkdirs(); file.remove(); if(!file.parent().remove()) message += "failed to remove this/is/a/ directory"; if(!file.parent().parent().parent().removeRecursive()) message += "failed to remove this directory"; } else { message += "External storage not available"; } FileHandle tmp = FileHandle::tempFile(); tmp.length(); message += "Temp file created: " + tmp.toString() + "\n"; tmp.remove(); tmp = FileHandle::tempDirectory(); if(!tmp.isDirectory()) fail(); message += "Temp directory created: " + tmp.toString() + "\n"; tmp.remove(); try { testInternal(); testExternal(); testAbsolute(); } catch(std::exception ex) { throw GdxRuntimeException(ex.what()); } }