コード例 #1
0
ファイル: a.cpp プロジェクト: Joan10/arducub
void loop(void) {
  for(uint8_t rotation=0; rotation<4; rotation++) {
    tft.setRotation(rotation);
    testText();
    delay(2000);
  }
}
コード例 #2
0
ファイル: shell.c プロジェクト: anizzomcItba/democles
static void
test()
{
	int i;

	for ( i = 0; i  < myCommands[COMMAND_TEST].qtyflags; i++)
	{

		if ( !strcmp(flags,myCommands[COMMAND_TEST].flags[i]))
		{
			switch(i)
			{
			case 0: testCommands();
			break;
			case 1: testText();
			break;
			default: ;

			}
			return;
		}

	}
	kprintf("Test: Invalid Options!\n");
}
コード例 #3
0
void CharIterTest::TestCoverage(){
    UnicodeString  testText("Now is the time for all good men to come to the aid of their country.");
    UnicodeString testText2("\\ud800\\udc01deadbeef");
    testText2 = testText2.unescape();
    SCharacterIterator* test = new SCharacterIterator(testText);
    if(test->firstPostInc()!= 0x004E){
        errln("Failed: firstPostInc() failed");
    }
    if(test->getIndex()!=1){
        errln("Failed: getIndex().");
    }
    if(test->getLength()!=testText.length()){
        errln("Failed: getLength()");
    }
    test->setToStart();
    if(test->getIndex()!=0){
        errln("Failed: setToStart().");
    }
    test->setToEnd();
    if(test->getIndex()!=testText.length()){
        errln("Failed: setToEnd().");
    }
    if(test->startIndex() != 0){
        errln("Failed: startIndex()");
    }
    test->setText(testText2);
    if(test->first32PostInc()!= testText2.char32At(0)){
        errln("Failed: first32PostInc() failed");
    }
 
    delete test;
    
}
コード例 #4
0
ファイル: application.cpp プロジェクト: albal/spark
void benchMark() {

    Serial.print(F("Text                     "));
    Serial.println(testRandomRects());
    delay(500);

    Serial.println(F("Benchmark                Time (microseconds)"));

    Serial.print(F("Screen fill              "));
    Serial.println(testFillScreen());
    delay(500);

    Serial.print(F("Text                     "));
    Serial.println(testText());
    delay(3000);


    Serial.print(F("Lines                    "));
    Serial.println(testLines(ILI9341_CYAN));
    delay(500);

    Serial.print(F("Horiz/Vert Lines         "));
    Serial.println(testFastLines(ILI9341_RED, ILI9341_BLUE));
    delay(500);

    Serial.print(F("Rectangles (outline)     "));
    Serial.println(testRects(ILI9341_GREEN));
    delay(500);

    Serial.print(F("Rectangles (filled)      "));
    Serial.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA));
    delay(500);

    Serial.print(F("Circles (filled)         "));
    Serial.println(testFilledCircles(10, ILI9341_MAGENTA));

    Serial.print(F("Circles (outline)        "));
    Serial.println(testCircles(10, ILI9341_WHITE));
    delay(500);

    Serial.print(F("Triangles (outline)      "));
    Serial.println(testTriangles());
    delay(500);

    Serial.print(F("Triangles (filled)       "));
    Serial.println(testFilledTriangles());
    delay(500);

    Serial.print(F("Rounded rects (outline)  "));
    Serial.println(testRoundRects());
    delay(500);

    Serial.print(F("Rounded rects (filled)   "));
    Serial.println(testFilledRoundRects());
    delay(500);

    Serial.println(F("Done!"));

}
コード例 #5
0
static gboolean
is_row_visible (GtkTreeModel * model, GtkTreeIter * iter, gpointer vdata)
{
  const char * text;
  tr_torrent * tor;
  struct filter_data * data = vdata;
  GObject * o = G_OBJECT (data->filter_model);

  gtk_tree_model_get (model, iter, MC_TORRENT, &tor, -1);

  text = (const char*) g_object_get_qdata (o, TEXT_KEY);

  return (tor != NULL) && test_torrent_activity (tor, data->active_activity_type)
                       && testText (tor, text);
}
コード例 #6
0
int main(int argc, char **argv) {
  atexit(exitHelper);

  KApplication app(argc, argv, "testeqparser", false, false);

  // Base cases
  test("0", 1.0, 0.0);
  test("1.0", 2.0, 1.0);

  // Basics
  test("x", -1.0, -1.0);
  test("-x", -1.0, 1.0);
  test("x^2", -1.0, 1.0);
  test("     x^2", -1.0, 1.0);
  test("     x^2    	   ", -1.0, 1.0);
  test("x^2	", -1.0, 1.0);
  test("x^2	+	x^2", -1.0, 2.0);
  test("y", 0.0, NOPOINT);
  test("foo()", 0.0, NOPOINT);
  test("foo(1.0, 2.0, 3.0)", 0.0, NOPOINT);

  // Order of evaluation and parser issues
  test("-x^2", 2.0, -4.0);
  test("(-x)^2", 2.0, 4.0);
  test("-(x^2)", 2.0, -4.0);
  test("(-x^2)", 2.0, -4.0);
  test("x*x+5", 2.0, 9.0);
  test("5+x*x", 2.0, 9.0);
  test("5*4/2*5", 1.0, 50.0);
  test("asin(sin(x))", 3.14159265358979323, 0.0);
  test("x^(1/2)", 2.0, sqrt(2.0));
  test("x^(1/2)*2", 2.0, 2.0*sqrt(2.0));
  test("(1/2)*x^2+3*x-5", 1.0, -1.5);
  test("2^3^4", 0.0, 2417851639229258349412352.0);
  test("sin(x)^2", 0.5*3.14159265358979323, 1.0);
  test("(2)^(3)", 0.0, 8);
  test("(2*3)^(3*4)", 0.0, 2176782336.0);
  test("sin(x^2)", sqrt(3.14159265358979323), 0.0);
  test("5*4/2", 0.0, 10.0);
  test("5/4*2", 0.0, 2.5);
  test("10%2", 0.0, 0.0);
  test("10.5%2", 0.0, 0.5);
  test("0%2", 0.0, 0.0);
  test("2%0", 0.0, NOPOINT);
  test("--x", 1.0, 1.0);
  test("--x", -1.0, -1.0);
  test("---x", -1.0, 1.0);
  test("---x", 1.0, -1.0);

  // Constants
  test("e", 0.0, 2.7128182846);
  test("pi", 0.0, 3.1415926536);

  // Functions
  test("sin()", 0.0, NOPOINT);
  test("sin(0.0)", 0.0, 0.0);
  test("sin(3.14159265358979323)", 0.0, 0.0);
  test("sin(3.14159265358979323/2.00000000000000000000000000)", 0.0, 1.0);
  test("cos()", 0.0, NOPOINT);
  test("cos(0.0)", 0.0, 1.0);
  test("cos(3.14159265358979323)", 0.0, -1.0);
  test("cos(3.14159265358979323/2.00000000000000000000000000)", 0.0, 0.0);
  test("sec(x) == 1/cos(x)", 0.2332744, 1.0);
  test("csc(x) == 1/sin(x)", 0.2332744, 1.0);
  test("cot(x) == 1/tan(x)", 0.2332744, 1.0);

  test("abs(0.0)", 0.0, 0.0);
  test("abs(x)", 1.0, 1.0);
  test("abs(x)", -1.0, 1.0);
  test("abs(x)", NOPOINT, NOPOINT);
  test("abs(x)", INF, INF);
  test("abs(x)", -INF, INF);
  test("abs(-0.000000000001)", 0.0, 0.000000000001);

  test("cos(acos(x))", 0.3875823288, 0.3875823288, 0.0000000001);
  test("acos(cos(x))", 2.3875823288, 2.3875823288, 0.0000000001);
  test("asin(sin(x))", 0.7540103248, 0.7540103248, 0.0000000001);
  test("sin(asin(x))", 0.3875823288, 0.3875823288, 0.0000000001);
  test("tan(atan(x))", 2.3875823288, 2.3875823288, 0.0000000001);
  test("atan(tan(x))", 0.3875823288, 0.3875823288, 0.0000000001);

  test("sqrt(4) == 2.0", 0.0, 1.0);
  test("sqrt(0) == 0.0", 0.0, 1.0);
  test("sqrt(-1)", 0.0, NOPOINT);
  test("sqrt(2)", 0.0, 1.4142135623730951);

  test("cbrt(0.0) == 0.0", 0.0, 1.0);
  test("cbrt(8.0) == 2.0", 0.0, 1.0);
  test("cbrt(-1)", 0.0, -1.0);
  test("cbrt(2)", 0.0, 1.2599210498948734);

  // TODO: cosh, exp, log, ln, sinh, tanh

  // Expressions / Comparison
  test("0.0>0.0", 0.0, 0.0);
  test("0.0>=0.0", 0.0, 1.0);
  test("0.0<0.0", 0.0, 0.0);
  test("0.0<=0.0", 0.0, 1.0);
  test("0.0=0.0", 0.0, 1.0);
  test("0.0!=0.0", 0.0, 0.0);
  test("1.0!=0.0", 0.0, 1.0);
  test("sin(1.0)!=sin(0.0)", 0.0, 1.0);
  test("sin()!=sin()", 0.0, 1.0);
  test("0.0==0.0", 0.0, 1.0);
  test("1.0>0.0", 0.0, 1.0);
  test("1.0>=0.0", 0.0, 1.0);
  test("0.0>1.0", 0.0, 0.0);
  test("0.0>=1.0", 0.0, 0.0);
  test("1.0<0.0", 0.0, 0.0);
  test("1.0<=0.0", 0.0, 0.0);
  test("0.0<1.0", 0.0, 1.0);
  test("0.0<=1.0", 0.0, 1.0);
  test("(0.0/0.0)==(0.0/0.0)", 0.0, 0.0);
  test("(0.0/0.0)==(1.0/0.0)", 0.0, 0.0);
  test("(1.0/0.0)==(1.0/0.0)", 0.0, 1.0); // inf == inf
  test("(1.0/0.0)==-(1.0/0.0)", 0.0, 0.0);
  test("(0.0/0.0)==-(1.0/0.0)", 0.0, 0.0);
  test("(1.0/0.0)==(0.0/0.0)", 0.0, 0.0);
  test("1&&1", 0.0, 1.0);
  test("1&&0", 0.0, 0.0);
  test("0&&1", 0.0, 0.0);
  test("0&&2", 0.0, 0.0);
  test("3&&2", 0.0, 1.0);
  test("1||1", 0.0, 1.0);
  test("0||1", 0.0, 1.0);
  test("1||0", 0.0, 1.0);
  test("0||0", 0.0, 0.0);
  test("2||4", 0.0, 1.0);
  test("1||(2&&0)", 0.0, 1.0);
  test("(1||2)&&0", 0.0, 0.0);
  test("1||2&&0", 0.0, 1.0);
  test("2&&0||1", 0.0, 1.0);
  test("2&&1||0", 0.0, 1.0);
  test("0||1&&0", 0.0, 0.0);
  test("1.0 == (1.0 == 1.0)", 0.0, 1.0);
  test("1.0 != (1.0 == 0.0)", 0.0, 1.0);
  test("1.0 != (1.0 == 1.0)", 0.0, 0.0);
  test("0.0 == (1.0 == 0.0)", 0.0, 1.0);
  test("-1==1", 0.0, 0.0);
  test("-1==-1", 0.0, 1.0);
  test("1==-1", 0.0, 0.0);
  test("1!=-1", 0.0, 1.0);
  test("-1!=1", 0.0, 1.0);
  test("-1!=-1", 0.0, 0.0);
  test("!0.0", 0.0, 1.0);
  test("!1.0", 0.0, 0.0);
  test("!-1.0", 0.0, 0.0);
  test("!2.0", 0.0, 0.0);
  test("!x", INF, 0.0);
  test("!x", NOPOINT, 1.0);
  test("!(1 > 2)", 0.0, 1.0);
  test("!1.0 > -1.0", 0.0, 1.0);  // (!1.0) > -1.0
  test("!!x", 1.0, 1.0);
  test("!!!x", 1.0, 0.0);
  test("!!!!x", 1.0, 1.0);

  // Bit operations
  test("32&4", 0.0, 0.0);
  test("32&4|2", 0.0, 2.0);
  test("32|4&2", 0.0, 0.0);
  test("32|4", 0.0, 36.0);
  test("0&257", 0.0, 0.0);
  test("257&0", 0.0, 0.0);
  test("257|0", 0.0, 257.0);
  test("0|257", 0.0, 257.0);
  test("-1|257", 0.0, -1);
  test("257|-1", 0.0, -1);

  // Scalars
  new KstScalar("test1", 0L, 1.0, true);
  new KstScalar("test2", 0L, 0.0, true);
  new KstScalar("test3", 0L, -1.0, true);
  new KstScalar("test4", 0L, NOPOINT, true);
  new KstScalar("test5", 0L, INF, true);
  new KstScalar("test6", 0L, -INF, true);

  test("[test1]", 0.0, 1.0);
  test("[test4]", 0.0, NOPOINT);
  test("[test4] - [test4]", 0.0, NOPOINT);
  test("[test4] - [test5]", 0.0, NOPOINT);
  test("[test4]*[test5]", 0.0, NOPOINT);
  test("[sdf]", 0.0, NOPOINT);

  test("[=10+10]", 0.0, 20.0);
  
  // Vectors
  KstVector::generateVector(0, 1.0, 10, "1");
  KstVector::generateVector(0, 1.0, 10, "V1");
  KstVector::generateVector(1.0, 2.0, 10, "V2");
  KstVector::generateVector(0, 1.0, 2, "V3");
  KstVector::generateVector(-1.0, 1.0, 1000, "V4");
  KstVector::generateVector(-1.0, 1.0, 1000, "V5-%+-_!");
  test("[V2] - [V1]", 0.0, 1.0);
  test("[V2[9]]", 0.0, 2.0);
  test("[V2[5+4]]", 0.0, 2.0);
  test("[V2[]]", 0.0, 1.0);
  test("2*sin([V5-%+-_!])", 0.0, -1.6829419696157930);
  // TODO: interpolation, more vector combinations

  // Plugins
  test("2*plugin(bin, [V4], 12)", 1.0, -1.9779779779779778);
  test("4*plugin(bin, [V4], x)", 5.0, -3.9839839839839839);
  test("-3*plugin(bin, x, 12)", 2.0, NOPOINT);
  xVector = KstVector::generateVector(0, 100, 2000, "XVector");
  test("-3*plugin(bin, x, 12)", 2.0, -0.8254127063531767);
  test("-3*plugin(bin, y, 12)", 2.0, NOPOINT);

  // TODO: more plugin tests

  // TODO: float notation

  // Combinations
  test("1|0&&0", 0.0, 0.0);
  test("0&&0|1", 0.0, 0.0);
  test("0&&1|0", 0.0, 0.0);
  test("0||1&1", 0.0, 1.0);
  test("0||2&1", 0.0, 0.0);
  test("2&1||0", 0.0, 0.0);
  test("1-1||0", 0.0, 0.0);
  test("2-2||0", 0.0, 0.0);
  test("0||2-2", 0.0, 0.0);
  test("8|2*2", 0.0, 12.0);
  test("2*2|8", 0.0, 12.0);
  test("[V1] > 0.0", 0.0, 0.0);
  test("[V1] > -1.0", 0.0, 1.0);
  test("[1] > 0.0", 0.0, 0.0);
  test("[1] > -1.0", 0.0, 1.0);

  test("-([V1]*sin([V1]*[V2])+[V3]*cos([V3]*[V3]))", 0.0, 0.0);
  test("[V3] * -1", 0.0, 0.0);

  /*  Wrap a testcase with this and run bison with -t in order to get a trace
   *  of the parse stack */
#if 0
  yydebug = 1;
  yydebug = 0;
#endif
  // Errors:
  testParseFail("");
  testParseFail(" ");
  testParseFail("\t");
  testParseFail(" \t \t");
  testParseFail("[]");
  testParseFail("[[]");
  testParseFail("[]]");
  testParseFail("]");
  testParseFail("[");
  testParseFail("][");
  testParseFail("[][");
  testParseFail("foo(, 3)");
  testParseFail("foo(3,)");
  testParseFail("foo(3,,5)");
  testParseFail("foo([])");
  testParseFail("foo(4, [])");
  testParseFail("/");
  testParseFail("/2");
  testParseFail("2/");
  testParseFail("2//2");
  testParseFail("%");
  testParseFail("%2");
  testParseFail("2%");
  testParseFail("2%%2");
  testParseFail("|");
  testParseFail("||");
  testParseFail("|2");
  testParseFail("2|");
  testParseFail("||2");
  testParseFail("2||");
  testParseFail("2|||2");
  testParseFail("&");
  testParseFail("&&");
  testParseFail("&2");
  testParseFail("2&");
  testParseFail("&&2");
  testParseFail("2&&");
  testParseFail("2&&&2");
  testParseFail("*");
  testParseFail("*2");
  testParseFail("2*");
  testParseFail("2**2");
  testParseFail("^");
  testParseFail("^2");
  testParseFail("2^^2");
  testParseFail("2^");
  testParseFail("+");
  testParseFail("+2");
  testParseFail("2+");
  testParseFail("2++2");
  testParseFail("-");
  testParseFail("2-");
  testParseFail("-2-");
  testParseFail("2!");
  testParseFail("!");
  testParseFail("()");
  testParseFail("2()");
  testParseFail("()2");
  testParseFail("_");
  testParseFail("#");
  testParseFail("$");
  testParseFail(")");
  testParseFail("(");
  testParseFail(")(");
  testParseFail("2&|2");
  testParseFail("2&&||2");
  testParseFail("2&&+2");
  testParseFail("2+&&2");
  testParseFail("2*&&2");
  testParseFail("2&&*2");
  testParseFail("2<>2");
  testParseFail("2=<2");
  testParseFail("2=>2");
  testParseFail("2><2");
  testParseFail("<");
  testParseFail("<2");
  testParseFail("2<");
  testParseFail("2<<2");
  testParseFail(">");
  testParseFail(">2");
  testParseFail("2>");
  testParseFail("2>>2");
  testParseFail(">=");
  testParseFail(">=2");
  testParseFail("2>=");
  testParseFail("2>=>=2");
  testParseFail("<=");
  testParseFail("<=2");
  testParseFail("2<=");
  testParseFail("2<=<=2");
  testParseFail("2<==2");
  testParseFail(".");
  testParseFail(".2");
  testParseFail("2.");
  testParseFail(",");
  testParseFail(",2");
  testParseFail("2,"); // Doesn't give a specific error - how to catch this?
  testParseFail("2*sin(x");
  testParseFail("2*sin(x)()");

  testText("3*x", "3*x");
  testText("(3*x)", "(3*x)");
  testText("3*(x)", "3*x");
  testText("((3*x))", "(3*x)");
  testText(" ((3 * x)) ", "(3*x)");
  testText(" ((3 * x)) ", "(3*x)");
  testText("(-3)", "(-3)");
  testText("(x)", "x");
  testText("(3*(-(x+5)))", "(3*(-(x+5)))");
  testText("(sin((x)))", "sin(x)");

  exitHelper();
  if (rc == KstTestSuccess) {
    printf("All tests passed!\n");
  }
  return -rc;
}
コード例 #7
0
ファイル: a.cpp プロジェクト: Joan10/arducub
void setup(void) {
  Serial.begin(9600);
  progmemPrintln(PSTR("TFT LCD test"));

#ifdef USE_ADAFRUIT_SHIELD_PINOUT
  progmemPrintln(PSTR("Using Adafruit 2.8\" TFT Arduino Shield Pinout"));
#else
  progmemPrintln(PSTR("Using Adafruit 2.8\" TFT Breakout Board Pinout"));
#endif

  tft.reset();

  uint16_t identifier = tft.readID();

  if(identifier == 0x9325) {
    progmemPrintln(PSTR("Found ILI9325 LCD driver"));
  } else if(identifier == 0x9328) {
    progmemPrintln(PSTR("Found ILI9328 LCD driver"));
  } else if(identifier == 0x7575) {
    progmemPrintln(PSTR("Found HX8347G LCD driver"));
  } else {
    progmemPrint(PSTR("Unknown LCD driver chip: "));
    Serial.println(identifier, HEX);
    progmemPrintln(PSTR("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
    progmemPrintln(PSTR("  #define USE_ADAFRUIT_SHIELD_PINOUT"));
    progmemPrintln(PSTR("should appear in the library header (Adafruit_TFT.h)."));
    progmemPrintln(PSTR("If using the breakout board, it should NOT be #defined!"));
    progmemPrintln(PSTR("Also if using the breakout, double-check that all wiring"));
    progmemPrintln(PSTR("matches the tutorial."));
    return;
  }

  tft.begin(identifier);

  progmemPrintln(PSTR("Benchmark                Time (microseconds)"));

  progmemPrint(PSTR("Screen fill              "));
  Serial.println(testFillScreen());
  delay(500);

  progmemPrint(PSTR("Text                     "));
  Serial.println(testText());
  delay(3000);

  progmemPrint(PSTR("Lines                    "));
  Serial.println(testLines(CYAN));
  delay(500);

  progmemPrint(PSTR("Horiz/Vert Lines         "));
  Serial.println(testFastLines(RED, BLUE));
  delay(500);

  progmemPrint(PSTR("Rectangles (outline)     "));
  Serial.println(testRects(GREEN));
  delay(500);

  progmemPrint(PSTR("Rectangles (filled)      "));
  Serial.println(testFilledRects(YELLOW, MAGENTA));
  delay(500);

  progmemPrint(PSTR("Circles (filled)         "));
  Serial.println(testFilledCircles(10, MAGENTA));

  progmemPrint(PSTR("Circles (outline)        "));
  Serial.println(testCircles(10, WHITE));
  delay(500);

  progmemPrint(PSTR("Triangles (outline)      "));
  Serial.println(testTriangles());
  delay(500);

  progmemPrint(PSTR("Triangles (filled)       "));
  Serial.println(testFilledTriangles());
  delay(500);

  progmemPrint(PSTR("Rounded rects (outline)  "));
  Serial.println(testRoundRects());
  delay(500);

  progmemPrint(PSTR("Rounded rects (filled)   "));
  Serial.println(testFilledRoundRects());
  delay(500);

  progmemPrintln(PSTR("Done!"));
}
コード例 #8
0
ファイル: wtest.c プロジェクト: awmaker/awmaker
int main(int argc, char **argv)
{
	WMScreen *scr;
	WMPixmap *pixmap;

	/* Initialize the application */
	WMInitializeApplication("Test@eqweq_ewq$eqw", &argc, argv);

	testUD();

	/*
	 * Open connection to the X display.
	 */
	dpy = XOpenDisplay("");

	if (!dpy) {
		puts("could not open display");
		exit(1);
	}

	/* This is used to disable buffering of X protocol requests.
	 * Do NOT use it unless when debugging. It will cause a major
	 * slowdown in your application
	 */
#if 0
	XSynchronize(dpy, True);
#endif
	/*
	 * Create screen descriptor.
	 */
	scr = WMCreateScreen(dpy, DefaultScreen(dpy));

	/*
	 * Loads the logo of the application.
	 */
	pixmap = WMCreatePixmapFromFile(scr, "logo.xpm");

	/*
	 * Makes the logo be used in standard dialog panels.
	 */
	if (pixmap) {
		WMSetApplicationIconPixmap(scr, pixmap);
		WMReleasePixmap(pixmap);
	}

	/*
	 * Do some test stuff.
	 *
	 * Put the testSomething() function you want to test here.
	 */

	testText(scr);
	testFontPanel(scr);

	testColorPanel(scr);

	testTextField(scr);

#if 0

	testBox(scr);
	testButton(scr);
	testColorPanel(scr);
	testColorWell(scr);
	testDragAndDrop(scr);
	testFrame(scr);
	testGradientButtons(scr);
	testList(scr);
	testOpenFilePanel(scr);
	testProgressIndicator(scr);
	testPullDown(scr);
	testScrollView(scr);
	testSlider(scr);
	testSplitView(scr);
	testTabView(scr);
	testTextField(scr);
#endif
	/*
	 * The main event loop.
	 *
	 */
	WMScreenMainLoop(scr);

	return 0;
}
コード例 #9
0
void CharIterTest::TestConstructionAndEquality() {
    UnicodeString  testText("Now is the time for all good men to come to the aid of their country.");
    UnicodeString  testText2("Don't bother using this string.");
    UnicodeString result1, result2, result3;

    CharacterIterator* test1 = new StringCharacterIterator(testText);
    CharacterIterator* test1b= new StringCharacterIterator(testText, -1);
    CharacterIterator* test1c= new StringCharacterIterator(testText, 100);
    CharacterIterator* test1d= new StringCharacterIterator(testText, -2, 100, 5);
    CharacterIterator* test1e= new StringCharacterIterator(testText, 100, 20, 5);
    CharacterIterator* test2 = new StringCharacterIterator(testText, 5);
    CharacterIterator* test3 = new StringCharacterIterator(testText, 2, 20, 5);
    CharacterIterator* test4 = new StringCharacterIterator(testText2);
    CharacterIterator* test5 = test1->clone();

    if (test1d->startIndex() < 0)
        errln("Construction failed: startIndex is negative");
    if (test1d->endIndex() > testText.length())
        errln("Construction failed: endIndex is greater than the text length");
    if (test1d->getIndex() < test1d->startIndex() || test1d->endIndex() < test1d->getIndex())
        errln("Construction failed: index is invalid");

    if (*test1 == *test2 || *test1 == *test3 || *test1 == *test4)
        errln("Construction or operator== failed: Unequal objects compared equal");
    if (*test1 != *test5)
        errln("clone() or equals() failed: Two clones tested unequal");

    if (test1->hashCode() == test2->hashCode() || test1->hashCode() == test3->hashCode()
                    || test1->hashCode() == test4->hashCode())
        errln("hashCode() failed:  different objects have same hash code");

    if (test1->hashCode() != test5->hashCode())
        errln("hashCode() failed:  identical objects have different hash codes");

    if(test1->getLength() != testText.length()){
        errln("getLength of CharacterIterator failed");
    }
    test1->getText(result1);
    test1b->getText(result2);
    test1c->getText(result3);
    if(result1 != result2 ||  result1 != result3)
        errln("construction failed or getText() failed");


    test1->setIndex(5);
    if (*test1 != *test2 || *test1 == *test5)
        errln("setIndex() failed");

    *((StringCharacterIterator*)test1) = *((StringCharacterIterator*)test3);
    if (*test1 != *test3 || *test1 == *test5)
        errln("operator= failed");

    delete test2;
    delete test3;
    delete test4;
    delete test5;
    delete test1b;
    delete test1c;
    delete test1d;
    delete test1e;

   
    StringCharacterIterator* testChar1=new StringCharacterIterator(testText);
    StringCharacterIterator* testChar2=new StringCharacterIterator(testText2);
    StringCharacterIterator* testChar3=(StringCharacterIterator*)test1->clone();

    testChar1->getText(result1);
    testChar2->getText(result2);
    testChar3->getText(result3); 
    if(result1 != result3 || result1 == result2)
        errln("getText() failed");
    testChar3->setText(testText2);
    testChar3->getText(result3);
    if(result1 == result3 || result2 != result3)
        errln("setText() or getText() failed");
    testChar3->setText(testText);
    testChar3->getText(result3);
    if(result1 != result3 || result1 == result2)
        errln("setText() or getText() round-trip failed");

    delete testChar1;
    delete testChar2;
    delete testChar3;
    delete test1;

}
コード例 #10
0
int main(int argc, char const *argv[])
{
  std::cout << "Travis make Test successful." << std::endl;

  TextWord test("blub", 0);

  if (test.exactMatch("b")) {
    std::cout << "found b !!! error" << std::endl;
  }
  if (test.exactMatch("xlub")) {
    std::cout << "found xlub!!! error" << std::endl;
  }
  if (test.exactMatch("blub")) {
    std::cout << "found blub" << std::endl;
  }
  if (test.partialMatch("b")) {
    std::cout << "found b" << std::endl;
  }
  if (test.partialMatch("xlub")) {
    std::cout << "found xlub!!! error" << std::endl;
  }
  if (test.partialMatch("lub")) {
    std::cout << "found lub" << std::endl;
  }
  if (test.partialMatch("blub")) {
    std::cout << "found blub" << std::endl;
  }
  
  test.status();

  TheText testText("input.txt");

  std::cout << "Total number of words: " << testText.wordCount() << std::endl;

  std::cout << "Count of 'der': " << testText.exactMatchCount("der") << std::endl;

  std::cout << "Occurances of 'der':" << std::endl;
  for (auto &&occurance :testText.getOccurances("der")) {
    std::cout << "Index: " << occurance << std::endl;
  }

  DirFileSearch testDir;
  testDir.addFile("Readme.md");

  for (auto &&item :testDir.files()) {
    std::cout << item << std::endl;
  }

  std::vector<std::string> files = testDir.files();
  auto result = testDir.exactSearchCount("der");
  for (auto &&element : result) {
    std::cout << "Count of 'der': "  << element.second << std::endl << "in file: " << element.first << std::endl;
  }

  auto result2 = testDir.exactSearchOccurances("der");
  for (auto &&item2 : result2) {
    std::cout << "Occurances of 'der' " << std::endl;
    if (item2.second.empty()) {
      std::cout << "not found";
    } else {
      for (auto &&occurance : item2.second) {
        std::cout << occurance << ", ";
      }
    }
    std::cout << std::endl << "in file: " << item2.first << std::endl;
  }

  /*for (unsigned int index = 0; index < result.size(); ++index) {
    std::cout << "Count of 'der': "  << result.at(index) << " in file: " << files.at(index) << std::endl;
  }
*/
  return 0;
}
コード例 #11
0
ファイル: graphics.c プロジェクト: kkadatoka/direct-spi
int main(int argc, char *argv[])
{
#ifdef __XENO__
	struct sched_param param = { 99 };
	mlockall(MCL_CURRENT | MCL_FUTURE);
	pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);
#endif

	if (!raspi_map_hw()) {
		perror("Could not map hardware registers");
		exit(1);
	}

#ifdef __XENO__
	pthread_set_mode_np(0, PTHREAD_WARNSW|PTHREAD_PRIMARY);
#endif

	//	ILI9341(int8_t _CS, int8_t _DC, int8_t _RST, int8_t _BL, int8_t _MOSI, int8_t _SCLK, int8_t _MISO);
	ILI9341 tft = ILI9341(PIN_CS, PIN_DC, PIN_RESET, PIN_BL, PIN_MOSI, PIN_SCLK, PIN_MISO);

	printf("Setting up TFT...\n");
	tft.begin();
	
	g_HWSPI=0;
	if (argc > 1)
	{
		g_HWSPI=1;
	}

	if (g_HWSPI)
	{
		printf("Setup HW SPI parameters...\n");
	}
	else
	{
		printf("Setup SW SPI (Bit-Banger) parameters...\n");
	}

	printf("HWReset done, initializing display\n") ;
	int i, colors[8] = { ILI9341_BLACK, ILI9341_BLUE, ILI9341_RED, ILI9341_GREEN, ILI9341_CYAN, ILI9341_MAGENTA, ILI9341_WHITE, ILI9341_YELLOW }; 
	begin();
	printf("Done intializing, now fill screens...\n");
	for (i=0;i<8 ;i++ )
	{
		fillScreen(ILI9341_BLACK);
		//sleep(1);
		fillScreen(colors[i]);
		//sleep (2);
	}
	printf("Setting up for HWreset\n");

	printf("Benchmark\tTime (microseconds)\n");

	printf("Screen fill\t%f\n", testFillScreen());
	sl_delay(500);

	printf("Text\t%f\n",testText());
	sl_delay(3000);

	printf("Lines\t%f\n",testLines(ILI9341_CYAN));
	sl_delay(500);

	printf("Horiz/Vert Lines\t%f\n", testFastLines(ILI9341_RED, ILI9341_BLUE));
	sl_delay(500);

	printf("Rectangles (outline)\t%f",testRects(ILI9341_GREEN));
	sl_delay(500);

	printf("Rectangles (filled)\t%f\n", testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA));
	sl_delay(500);

	printf("Circles (filled)\t%f\n", testFilledCircles(10, ILI9341_MAGENTA));

	printf("Circles (outline)\t%f\n", testCircles(10, ILI9341_WHITE));
	sl_delay(500);

	printf("Triangles (outline)\t%f\n", testTriangles());
	sl_delay(500);

	printf("Triangles (filled)\t%f\n", testFilledTriangles());
	sl_delay(500);

	printf("Rounded rects (outline)\t%f\n", testRoundRects());
	sl_delay(500);

	printf("Rounded rects (filled)\t%f\n", testFilledRoundRects());
	sl_delay(500);

	printf("Done!\n");

	for(uint8_t rotation=0; rotation<4; rotation++) 
	{
		tft.setRotation(rotation);
		testText();
		sl_delay(1000);
	}

#ifdef __XENO__
	pthread_set_mode_np(PTHREAD_WARNSW, 0);
#endif

	return 1;
}