2013-07-11 11:23:25 +02:00
|
|
|
/**
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
*
|
|
|
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
|
|
*
|
|
|
|
* @license BSD v3 (see license file)
|
|
|
|
*/
|
|
|
|
|
2013-10-25 20:47:46 +02:00
|
|
|
#include <etk/debug.h>
|
2013-11-11 20:16:55 +01:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2013-10-18 22:05:48 +02:00
|
|
|
#include <etk/Hash.h>
|
2013-07-11 11:23:25 +02:00
|
|
|
#include <etk/os/FSNode.h>
|
2013-07-24 07:42:25 +02:00
|
|
|
#include <etk/archive/Archive.h>
|
2013-07-11 11:23:25 +02:00
|
|
|
|
|
|
|
#undef __class__
|
|
|
|
#define __class__ "etktest"
|
|
|
|
|
2013-11-11 20:16:55 +01:00
|
|
|
void testVector(void) {
|
2013-07-11 11:23:25 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-11 20:16:55 +01:00
|
|
|
void testUChar(void) {
|
2013-07-11 11:23:25 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-11 20:16:55 +01:00
|
|
|
void testUString(void) {
|
2013-07-11 11:23:25 +02:00
|
|
|
|
|
|
|
for(int32_t iii=0; iii<64; iii++) {
|
|
|
|
int64_t kkk=((int64_t)1)<<iii;
|
2013-11-11 20:16:55 +01:00
|
|
|
std::u32string plop(kkk, std::u32string::printModeBinary);
|
2013-07-11 11:23:25 +02:00
|
|
|
TK_DEBUG(" test : " << plop);
|
|
|
|
}
|
|
|
|
for(int32_t iii=0; iii<64; iii++) {
|
|
|
|
int64_t kkk=((int64_t)1)<<iii;
|
2013-11-11 20:16:55 +01:00
|
|
|
std::u32string plop(kkk, std::u32string::printModeOctal);
|
2013-07-11 11:23:25 +02:00
|
|
|
TK_DEBUG(" test : " << plop);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int32_t iii=0; iii<64; iii++) {
|
|
|
|
int64_t kkk=((int64_t)1)<<iii;
|
2013-11-11 20:16:55 +01:00
|
|
|
std::u32string plop(kkk, std::u32string::printModeDecimal);
|
2013-07-11 11:23:25 +02:00
|
|
|
TK_DEBUG(" test : " << plop);
|
2013-10-09 21:49:40 +02:00
|
|
|
int64_t resTest = plop.toInt32();
|
2013-07-11 11:23:25 +02:00
|
|
|
TK_DEBUG(" test : " << resTest);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int32_t iii=0; iii<64; iii++) {
|
|
|
|
int64_t kkk=((int64_t)1)<<iii;
|
2013-11-11 20:16:55 +01:00
|
|
|
std::u32string plop(kkk, std::u32string::printModeHexadecimal);
|
2013-07-11 11:23:25 +02:00
|
|
|
TK_DEBUG(" test : " << plop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-11 20:16:55 +01:00
|
|
|
void testHash(void) {
|
2013-07-11 13:35:49 +02:00
|
|
|
TK_INFO("==> Start test of Hach table");
|
2013-11-11 20:16:55 +01:00
|
|
|
etk::Hash<std::u32string> testData;
|
2013-10-09 21:49:40 +02:00
|
|
|
testData.add("TEST", "testData");
|
|
|
|
testData.add("TEST", "testData333");
|
|
|
|
testData.add("TEST2", "22222222222222222");
|
|
|
|
testData.add("TEST4", "4444444444444444444");
|
|
|
|
testData.add("TEST3", "3333333333");
|
|
|
|
testData.add("TEST1", "11111111111");
|
|
|
|
testData.add("TEST55", "555555555555555((((5555");
|
|
|
|
TK_INFO(" count =" << testData.size());
|
|
|
|
for (int32_t iii=0; iii< testData.size(); iii++) {
|
|
|
|
TK_INFO(" id=" << iii << " key='" << testData.getKey(iii) << "' val='" << testData.getValue(iii) << "'");
|
2013-07-11 13:35:49 +02:00
|
|
|
}
|
|
|
|
TK_INFO(" direct acces at the key key='TEST4' val='" << testData["TEST4"] << "'");
|
|
|
|
TK_INFO("==> End test of Hach table");
|
2013-07-11 11:23:25 +02:00
|
|
|
}
|
|
|
|
|
2013-11-11 20:16:55 +01:00
|
|
|
void testFSNode(void) {
|
2013-07-11 11:23:25 +02:00
|
|
|
TK_INFO("==> Start test of FSNode");
|
2013-11-11 20:16:55 +01:00
|
|
|
std::u32string fileName("USERDATA:myFileTest.txt");
|
2013-07-11 11:23:25 +02:00
|
|
|
etk::FSNode myNodeTest1(fileName);
|
|
|
|
TK_INFO("********************************************");
|
|
|
|
TK_INFO("** Filename=\"" << fileName << "\"");
|
|
|
|
TK_INFO("********************************************");
|
2013-10-09 21:49:40 +02:00
|
|
|
TK_INFO(" GetNameFolder() =\"" <<myNodeTest1.getNameFolder() << "\"");
|
|
|
|
TK_INFO(" GetName() =\"" <<myNodeTest1.getName() << "\"");
|
|
|
|
TK_INFO(" GetNameFile() =\"" <<myNodeTest1.getNameFile() << "\"");
|
|
|
|
TK_INFO(" GetRelativeFolder() =\"" <<myNodeTest1.getRelativeFolder() << "\"");
|
|
|
|
TK_INFO(" exist =" <<myNodeTest1.exist());
|
|
|
|
if (true==myNodeTest1.exist()) {
|
2013-07-11 11:23:25 +02:00
|
|
|
TK_ERROR(" ==> remove the file ==> bad for the test");
|
|
|
|
} else {
|
|
|
|
TK_INFO(" Display time when file does not exist :");
|
2013-10-09 21:49:40 +02:00
|
|
|
TK_INFO(" TimeCreatedString() =\"" <<myNodeTest1.timeCreatedString() << "\"");
|
|
|
|
TK_INFO(" TimeModifiedString() =\"" <<myNodeTest1.timeModifiedString() << "\"");
|
|
|
|
TK_INFO(" TimeAccessedString() =\"" <<myNodeTest1.timeAccessedString() << "\"");
|
2013-07-11 11:23:25 +02:00
|
|
|
}
|
2013-10-09 21:49:40 +02:00
|
|
|
myNodeTest1.touch();
|
|
|
|
if (false==myNodeTest1.exist()) {
|
2013-07-11 11:23:25 +02:00
|
|
|
TK_ERROR(" ==> Error, can not create the file ....");
|
|
|
|
} else {
|
|
|
|
TK_INFO(" Display time when file does exist :");
|
2013-10-09 21:49:40 +02:00
|
|
|
TK_INFO(" TimeCreatedString() =\"" <<myNodeTest1.timeCreatedString() << "\"");
|
|
|
|
TK_INFO(" TimeModifiedString() =\"" <<myNodeTest1.timeModifiedString() << "\"");
|
|
|
|
TK_INFO(" TimeAccessedString() =\"" <<myNodeTest1.timeAccessedString() << "\"");
|
2013-07-11 11:23:25 +02:00
|
|
|
}
|
|
|
|
// Try remove the file :
|
2013-10-09 21:49:40 +02:00
|
|
|
myNodeTest1.remove();
|
|
|
|
if (true==myNodeTest1.exist()) {
|
2013-07-11 11:23:25 +02:00
|
|
|
TK_ERROR(" ==> The file might be removed ==> but it is not the case ...");
|
|
|
|
} else {
|
|
|
|
TK_INFO(" ==> The file is removed");
|
|
|
|
}
|
|
|
|
TK_INFO("********************************************");
|
|
|
|
TK_INFO("==> Stop test of FSNode");
|
|
|
|
}
|
|
|
|
|
2013-07-24 07:42:25 +02:00
|
|
|
|
2013-11-11 20:16:55 +01:00
|
|
|
void testArchive(void) {
|
2013-07-24 07:42:25 +02:00
|
|
|
TK_INFO("==> Start test of archive");
|
2013-10-09 21:49:40 +02:00
|
|
|
etk::Archive* tmpArchive = etk::Archive::load("testzip.zip");
|
|
|
|
tmpArchive->display();
|
2013-07-24 07:42:25 +02:00
|
|
|
|
|
|
|
TK_INFO("==> End test of archive");
|
|
|
|
}
|
|
|
|
|
2013-07-11 11:23:25 +02:00
|
|
|
/*
|
2013-11-11 20:16:55 +01:00
|
|
|
void testDimension(void) {
|
2013-07-11 11:23:25 +02:00
|
|
|
TK_INFO("==> test of Dimension (START)");
|
|
|
|
|
|
|
|
ewol::Dimension myDimention(vec2(5,5), ewol::Dimension::Centimeter);
|
|
|
|
TK_INFO(" set dimension at : " << myDimention);
|
|
|
|
TK_INFO(" set dimension at : " << myDimention.GetCentimeter() << " cm");
|
|
|
|
TK_INFO(" set dimension at : " << myDimention.GetMillimeter() << " mm");
|
|
|
|
TK_INFO(" set dimension at : " << myDimention.GetKilometer() << " km");
|
|
|
|
TK_INFO(" set dimension at : " << myDimention.GetMeter() << " m");
|
|
|
|
TK_INFO(" set dimension at : " << myDimention.GetInch() << " Inch");
|
|
|
|
TK_INFO(" set dimension at : " << myDimention.GetFoot() << " ft");
|
|
|
|
TK_INFO(" set dimension at : " << myDimention.GetPourcent() << " %");
|
|
|
|
TK_INFO(" set dimension at : " << myDimention.GetPixel() << " px");
|
|
|
|
|
|
|
|
TK_INFO("==> test of Dimension (STOP)");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
*/
|
2013-11-11 20:16:55 +01:00
|
|
|
int main(int argc, const char *argv[]) {
|
2013-07-11 11:23:25 +02:00
|
|
|
// the only one init for etk:
|
2013-11-11 20:16:55 +01:00
|
|
|
debug::setGeneralLevel(etk::logLevelVerbose);
|
2013-07-11 13:35:49 +02:00
|
|
|
//testVector();
|
2013-10-18 21:15:02 +02:00
|
|
|
//testUChar();
|
2013-07-11 13:35:49 +02:00
|
|
|
//testUString();
|
2013-07-11 11:23:25 +02:00
|
|
|
testHash();
|
2013-07-11 13:35:49 +02:00
|
|
|
//testFSNode();
|
2013-07-11 11:23:25 +02:00
|
|
|
//testDimension();
|
2013-07-24 07:42:25 +02:00
|
|
|
testArchive();
|
2013-07-11 11:23:25 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|