コード例 #1
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* testLambda(){
    Test* t = createTest();
    int data[] = { 0, 2, 0, 0 };
    heapAdd(t->h,LAMBDA,data);
    push(&(t->s),0);
    return t;
}
コード例 #2
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* testBigdata(){
    Test* t = createTest();
    int data[] = { 2, 0, 0, 0 };
    heapAdd(t->h,BIGDATA,data);
    push(&(t->s),0);
    return t;
}
コード例 #3
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* testRange(){
    Test* t = createTest();
    int data[] = { 0, 0 };
    heapAdd(t->h,RANGE,data);
    push(&(t->s),0);
    return t;
}
コード例 #4
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* test2(){
    Test* t = createTest();
    push(&(t->s),24);
    push(&(t->s),13);
    push(&(t->s),0);

    collectioncount = 2;
    int data[] = { 2,4,28 };
    int bigdata[] = { 3,1,19,21,2 };
    int range[] = { 0,32 };
    int lambda[] = { 8,1,6 };
    int phantom[] = { 4,1 };
    int* soft = malloc(sizeof(int));
    *soft = 0;
    int* weak = malloc(sizeof(int));
    *weak = 2;

    //build test heap
    heap* h = t->h;
    heapAdd(h,INT,inn);
    heapAdd(h,BOOL,boo);
    heapAdd(h,WEAK,weak);
    heapAdd(h,STRING,str);
    heapAdd(h,BIGDATA,bigdata);
    heapAdd(h,LAMBDA,lambda);
    heapAdd(h,INT,inn);
    heapAdd(h,RANGE,range);
    heapAdd(h,DATA,data);
    heapAdd(h,SOFT,soft);
    heapAdd(h,BIGDATA,bigdata);
    heapAdd(h,PHANTOM,phantom);

    return t;
}
コード例 #5
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* testString(){
    Test* t = createTest();
    char* data = "hello";
    heapAdd(t->h,STRING,data);
    push(&(t->s),0);
    return t;
}
コード例 #6
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* testInt(){
    Test* t = createTest();
    int* data = malloc(sizeof(int)); *data = 5;
    heapAdd(t->h,INT,data);
    push(&(t->s),0);
    return t;
}
コード例 #7
0
ファイル: demo_step.cpp プロジェクト: joao-lima/opende_kaapi
int main (int argc, char **argv)
{
  // setup pointers to drawstuff callback functions
  dsFunctions fn;
  fn.version = DS_VERSION;
  fn.start = &start;
  fn.step = &simLoop;
  fn.command = 0;
  fn.stop = 0;
  fn.path_to_textures = DRAWSTUFF_TEXTURE_PATH;

  alloc_arrays();

  dInitODE2(0);
  dRandSetSeed (time(0));

  createTest();

  // run simulation
#pragma kaapi parallel
  dsSimulationLoop (argc,argv,352,288,&fn);

  dWorldDestroy (world);
  dCloseODE();

  return 0;
}
コード例 #8
0
ファイル: demo_step.cpp プロジェクト: joao-lima/opende_kaapi
static void simLoop (int pause)
{
  if (!pause) {
    // add random forces and torques to all bodies
    int i;
    const dReal scale1 = 5;
    const dReal scale2 = 5;

    for (i=0; i<NUM; i++) {
      dBodyAddForce (body[i],
		     scale1*(dRandReal()*2-1),
		     scale1*(dRandReal()*2-1),
		     scale1*(dRandReal()*2-1));
      dBodyAddTorque (body[i],
		     scale2*(dRandReal()*2-1),
		     scale2*(dRandReal()*2-1),
		     scale2*(dRandReal()*2-1));
    }

    dWorldStep (world,0.05);
    createTest();
  }

  // float sides[3] = {SIDE,SIDE,SIDE};
  dsSetColor (1,1,0);
  for (int i=0; i<NUM; i++)
    dsDrawSphere (dBodyGetPosition(body[i]), dBodyGetRotation(body[i]),RADIUS);
}
コード例 #9
0
 Layer* nextAction()
 {
     sceneIdx++;
     sceneIdx = sceneIdx % TEST_CASE_COUNT;
     
     return createTest(sceneIdx);
 }
コード例 #10
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* testWeak(){
    Test* t = createTest();
    int* data = malloc(sizeof(int)); *data = 0;
    heapAdd(t->h,WEAK,data);
    push(&(t->s),0);
    return t;
}
コード例 #11
0
 Layer* backAction()
 {
     sceneIdx--;
     if( sceneIdx < 0 )
         sceneIdx = TEST_CASE_COUNT -1;
     
     return createTest(sceneIdx);
 }
コード例 #12
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* scavengeWeakNoExists(){
    Test* t = createTest();
    int* data = malloc(sizeof(int)); *data = 0;
    heapAdd(t->h, INT, inn);
    heapAdd(t->h, WEAK, data);

    push(&(t->s), 2);
    return t;
}
コード例 #13
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* testPhantom(){
    Test* t = createTest();
    int data[] = { 0,1 };
    heapAdd(t->h,PHANTOM,data);
    int data1[] = { 0,0 };
    heapAdd(t->h,PHANTOM,data1);
    push(&(t->s),0);
    return t;
}
コード例 #14
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* testBool(){
    Test* t = createTest();
    int* data = malloc(sizeof(int)); *data = 0;
    heapAdd(t->h,BOOL,data);
    data = malloc(sizeof(int)); *data = 1;
    heapAdd(t->h,BOOL,data);
    push(&(t->s),0);
    push(&(t->s),2);
    return t;
}
コード例 #15
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* scavengePhantomNoFinal(){
    Test* t = createTest();
    int data[] = { 0,1 };

    heapAdd(t->h, INT, inn);
    heapAdd(t->h, PHANTOM, data);

    push(&(t->s), 2);
    return t;
}
コード例 #16
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* scavengeLambda(){
    Test* t = createTest();

    int data[] = {0,2,0,2};
    heapAdd(t->h, INT, inn);
    heapAdd(t->h, BOOL, boo);
    heapAdd(t->h, LAMBDA, data);

    push(&(t->s),4);
    return t;   
}
コード例 #17
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* scavengeRange(){
    Test* t = createTest();

    int data[] = { 0, 5};
    heapAdd(t->h, INT, inn);
    heapAdd(t->h, RANGE, data);
    heapAdd(t->h, STRING, str);

    push(&(t->s),2);
    return t;
}
コード例 #18
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* scavengeBD(){
    Test* t = createTest();

    int data[] = {2,0,0,2};
    heapAdd(t->h, INT, inn);
    heapAdd(t->h, BOOL, boo);
    heapAdd(t->h, BIGDATA, data);

    push(&(t->s),4);
    return t;
}
コード例 #19
0
ファイル: Box2DDemo.cpp プロジェクト: Robert-yeh/Kiwano
    void changeListenerCallback (ChangeBroadcaster* source) override
    {
        if (source == &testsListModel)
        {
            const int index = testsListBox.getSelectedRow();

            renderComponent.currentTest = createTest (index);
            instructions.setText (getInstructions (index));

            repaint();
        }
    }
コード例 #20
0
ファイル: testgc.c プロジェクト: lborwell/gc
void testComp(int i){
    Test* t = createTest();
    int j;
    int* r = malloc(sizeof(int)*2);
    r[0] = 0;
    for(j=0; j<i; j++){
        r[1] = (j+1)*3;
        heapAdd(t->h,RANGE,r);
    }
    //simplePrintHeap(t->h);
    push(&(t->s),0);
    collect(t->s, &(t->h), 0);
}
コード例 #21
0
int main(int argc, char **argv) {
	SceUID mutex;
	int i;
	u32 options[32];
	memset(options, 0, sizeof(options));
	
	checkpointNext("Names:");
	createTest("  NULL name", NULL, 0, 0, NULL);
	createTest("  Blank name", "", 0, 0, NULL);
	createTest("  Long name", "1234567890123456789012345678901234567890123456789012345678901234", 0, 0, NULL);

	SceUID mutex1 = sceKernelCreateMutex("create", 0, 0, NULL);
	SceUID mutex2 = sceKernelCreateMutex("create", 0, 0, NULL);
	if (mutex1 > 0 && mutex2 > 0) {
		checkpoint("  Two with same name: OK");
	} else {
		checkpoint("  Two with same name: Failed (%X, %X)", mutex1, mutex2);
	}
	sceKernelDeleteMutex(mutex1);
	sceKernelDeleteMutex(mutex2);

	checkpointNext("Attributes:");
	const static int attrs[] = {1, 0x100, 0x200, 0x400, 0x800, 0xB00, 0xBFF, 0xC00, 0x1000, 0x2000, 0x4000, 0x8000, 0x10000};
	for (i = 0; i < ARRAY_SIZE(attrs); ++i) {
		char temp[32];
		sprintf(temp, "  %x", attrs[i]);
		createTest(temp, "create", attrs[i], 0, NULL);
	}

	checkpointNext("Counts:");
	createTest("  Negative count", "create", 0, -1, NULL);
	createTest("  Positive count", "create", 0, 1, NULL);
	createTest("  Large count", "create", 0, 65537, NULL);

	checkpointNext("Option sizes:");
	const static int optionSizes[] = {-1, 0, 1, 4, 8, 16, 32, 64, 256, 0x7FFFFFFF};
	for (i = 0; i < ARRAY_SIZE(optionSizes); ++i) {
		char temp[32];
		sprintf(temp, "  %d", optionSizes[i]);
		options[0] = optionSizes[i];
		createTest(temp, "create", 0, 1, options);
	}

	checkpointNext("Scheduling:");
	BASIC_SCHED_TEST("NULL name",
		mutex = sceKernelCreateMutex(NULL, 0, 0, NULL);
		result = mutex > 0 ? 1 : mutex;
	);
コード例 #22
0
ファイル: testgc.c プロジェクト: lborwell/gc
Test* bigdatanocoll(){
    Test* t = createTest();
    push(&(t->s),0);

    collectioncount = 1;
    int bigdata[] = { 3,1,0,0,0 };
    
    //build test heap
    heap* h = t->h;
    heapAdd(h,BIGDATA,bigdata);
    heapAdd(h,BIGDATA,bigdata);

    return t;
}
コード例 #23
0
ファイル: Utest.cpp プロジェクト: KevinWMatthews/cpputest
void UtestShell::runOneTestInCurrentProcess(TestPlugin* plugin, TestResult& result)
{
    plugin->runAllPreTestAction(*this, result);

    //save test context, so that test class can be tested
    UtestShell* savedTest = UtestShell::getCurrent();
    TestResult* savedResult = UtestShell::getTestResult();

    result.countRun();
    UtestShell::setTestResult(&result);
    UtestShell::setCurrentTest(this);

    Utest* testToRun = createTest();
    testToRun->run();
    destroyTest(testToRun);

    UtestShell::setCurrentTest(savedTest);
    UtestShell::setTestResult(savedResult);

    plugin->runAllPostTestAction(*this, result);
}
コード例 #24
0
namespace test {

template <typename T>
class ConstructorFailTest {
  public:
    constexpr ConstructorFailTest (
        T intVal,
        uint64_t fracVal,
        uint8_t dp,
        Number::Sign sign
    )
      : intVal_ (intVal),
        fracVal_ (fracVal),
        dp_ (dp),
        sign_ (sign),
        strVal_ (""),
        useStringTest_ (false)
    {
    }

    constexpr ConstructorFailTest (
        const std::string& strVal
    )
      : intVal_ (0),
        fracVal_ (0),
        dp_ (0),
        sign_ (Number::Sign::POSITIVE),
        strVal_ (strVal),
        useStringTest_ (true)
    {
    }

    bool operator() ()
    {
        try {
            if (useStringTest_)
            {
                Number n (strVal_);

                std::cerr << "Error, string constructor expected exception "
                          << "for " << n.toString ()
                          << std::endl;
            }
            else
            {
                Number n (intVal_, fracVal_, dp_, sign_);

                std::cerr << "Error, value constructor expected exception for "
                          << n.toString ()
                          << std::endl;
            }

            return false;
        }
        catch (const fixed::BadValueException&)
        {
        }

        return true;
    }

  private:
    T intVal_;
    uint64_t fracVal_;
    unsigned int dp_;
    Number::Sign sign_;
    std::string strVal_;
    bool useStringTest_;
};

template <typename T>
constexpr Test createTest (
    const T intVal,
    const uint64_t fracVal,
    const uint8_t dp,
    const Number::Sign sign,
    const std::string& testName
)
{
    return Test (
        ConstructorFailTest<T> (intVal, fracVal, dp, sign),
        TestName (testName)
    );
}

Test createTest (const std::string& strVal)
{
    return Test (
        ConstructorFailTest<int> (strVal),
        TestName ("'" + strVal + "'")
    );
}

static const Number::Sign NEG = Number::Sign::NEGATIVE;
static const Number::Sign POS = Number::Sign::POSITIVE;

std::vector<Test> NumberIntConstructorFailTestVec = {
    createTest (9223372036854775808ULL, 0, 0, POS, "2^63"),
    createTest ("9223372036854775808"),

    createTest (-9223372036854775807 - 1, 0, 0, POS, "-2^63"),
    createTest (9223372036854775808ULL, 0, 0, NEG, "-2^63"),
    createTest ("-9223372036854775808"),

    createTest (18446744073709551615ULL, 0, 0, POS, "2^64-1"),
    createTest (18446744073709551615ULL, 0, 0, NEG, "-2^64-1"),
    createTest ("18446744073709551615"),
    createTest ("118446744073709551615"),
    createTest (18446744073709551615ULL, 999999999999999999, 18, POS, "BIGP"),
    createTest (18446744073709551615ULL, 999999999999999999, 18, NEG, "BIGN"),
    createTest ("18446744073709551615.999999999999999999"),
    createTest ("-18446744073709551615.999999999999999999"),

    createTest (0, 123456789012345, 14, POS, "Fraction value too large 1"),
    createTest (0, 123456789012345, 15, POS, "Fraction value too large 2"),
    createTest ("0.123456789012345"),
    createTest (".123456789012345"),
    createTest ("0.-1234"),
    createTest ("0.ab324"),
    createTest ("ewr"),
    createTest ("+ewr"),
    createTest ("-ewr"),
    createTest ("-11234K435"),
    createTest ("-11234435B"),
    createTest ("-11234435.0B"),
    createTest (""),
    createTest ("."),
    createTest ("1.")
};

} // namespace test
コード例 #25
0
ファイル: lrh.cpp プロジェクト: MagnusJohnsson/wysiwyd
// Understanding
bool LRH::sentenceToMeaning(string sentence){
    copyPastTrainFile(scorpusFileAP.c_str(), stemporaryCorpus.c_str());
    createTest(stemporaryCorpus.c_str(), sentence);
    callReservoir(sreservoirAP, sclosed_class_wordsAP);
    return true;
}
コード例 #26
0
namespace test {
 
//
// There are separate tests for rounding, all results for the arithmetic tests
// here will be using this rounding mode.
//
static const Rounding::Mode FP_CONSTRUCTOR_TEST_ROUNDING_MODE =
    Rounding::Mode::TO_NEAREST_HALF_TO_EVEN;

template <typename T>
class ConstructorTest {
  public:
    ConstructorTest (
        const T floatVal,
        unsigned int dp,
        unsigned int expectedDp,
        uint64_t expectedIntVal,
        uint64_t expectedFracVal,
        const std::string& expectedStrVal,
        const bool expectedVal64Set
    )
      : floatVal_ (floatVal),
        dp_ (dp),
        expectedDp_ (expectedDp),
        expectedIntVal_ (expectedIntVal),
        expectedFracVal_ (expectedFracVal),
        expectedStrVal_ (expectedStrVal),
        expectedNegative_ (floatVal < 0.0),
        expectedVal64Set_ (expectedVal64Set)
    {
    }

    bool operator() ()
    {
        Number::setDefaultRoundingMode (FP_CONSTRUCTOR_TEST_ROUNDING_MODE);

        //
        // Note, since we're doing constructor tests, must use the full version
        // of checkNumber here, not the shortened version that takes a
        // reference number object.  The other Number tests can use that
        // version, however here we must ensure the constructors themselves
        // are constructing the number properly, then it's valid for those
        // other tests to use the shortened version.
        //
        std::string name =
            std::string ("Floating Point Constructor ") + typeid (T).name ();

        return
            checkNumber (
                name,
                Number::floatingPoint (floatVal_, dp_),
                expectedStrVal_,
                expectedIntVal_,
                expectedFracVal_,
                expectedDp_,
                expectedNegative_,
                expectedVal64Set_
            )
        ;
    }

  private:
    T floatVal_;
    unsigned int dp_;
    unsigned int expectedDp_;
    uint64_t expectedIntVal_;
    uint64_t expectedFracVal_;
    std::string expectedStrVal_;
    bool expectedNegative_;
    uint64_t expectedVal64Set_;
};

static const bool V64 = true;
static const bool V128 = ! V64;

template <typename T>
constexpr Test createTest (
    const T floatVal,
    unsigned int dp,
    unsigned int expectedDp,
    uint64_t expectedIntVal,
    uint64_t expectedFracVal,
    const std::string& expectedStrVal,
    const bool expectedVal64Set
)
{
    return Test (
        ConstructorTest<T> (
            floatVal,
            dp,
            expectedDp,
            expectedIntVal,
            expectedFracVal,
            expectedStrVal,
            expectedVal64Set
        ),
        TestName (expectedStrVal)
    );
}

std::vector<Test> NumberFpConstructorTestVec = {
    createTest (1.2f, 2, 2, 1, 20, "1.20", V64),
    createTest (1.2, 2, 2, 1, 20, "1.20", V64),
    createTest (1.2L, 2, 2, 1, 20, "1.20", V64),
    createTest (1.123456f, 5, 5, 1, 12346, "1.12346", V64),
    createTest (1.123456, 5, 5, 1, 12346, "1.12346", V64),
    createTest (1.123456L, 5, 5, 1, 12346, "1.12346", V64),
    createTest (-1.2f, 2, 2, 1, 20, "-1.20", V64),
    createTest (-1.2, 2, 2, 1, 20, "-1.20", V64),
    createTest (-1.2L, 2, 2, 1, 20, "-1.20", V64),
    createTest (-1.123456f, 5, 5, 1, 12346, "-1.12346", V64),
    createTest (-1.123456, 5, 5, 1, 12346, "-1.12346", V64),
    createTest (-1.123456L, 5, 5, 1, 12346, "-1.12346", V64),

    createTest (
        1234567891012345678.2L,
        1,
        1,
        1234567891012345678,
        2,
        "1234567891012345678.2",
        V128
    ),

    createTest (
        -1234567891012345678.2L,
        1,
        1,
        1234567891012345678,
        2,
        "-1234567891012345678.2",
        V128
    ),

    //
    // By passing in max decimal places + 1 we trigger the decimal place
    // minimization Number will do by trimming excess zeros.
    //
    createTest (
        3.200000, Number::MAX_DECIMAL_PLACES + 1, 1, 3, 2, "3.2", V64
    )

};

} // namespace test
コード例 #27
0
namespace test {

template <typename T>
class ConstructorFailTest {
public:
    constexpr ConstructorFailTest (const T floatVal)
        : floatVal_ (floatVal)
    {
    }

    bool operator() ()
    {
        try {
            Number n = Number::floatingPoint (floatVal_);

            std::cerr << "Error, value constructor expected exception for "
                      << n.toString ()
                      << std::endl;

            return false;
        }
        catch (const fixed::BadValueException)
        {
        }

        return true;
    }

private:
    T floatVal_;
};

template <typename T>
constexpr Test createTest (
    const T floatVal,
    const std::string& testName
)
{
    return Test (
               ConstructorFailTest<T> (floatVal),
               TestName (testName)
           );
}

std::vector<Test> NumberFpConstructorFailTestVec = {
    createTest (9300000000000000000.0000000000f, "~ 2^63"),
    createTest (9300000000000000000.0000000000, "~ 2^63"),
    createTest (9223372036854775808.0000000000L, "2^63"),

    createTest (-9300000000000000000.0000000000f, "~ -2^63"),
    createTest (-9300000000000000000.0000000000, "~ -2^63"),
    createTest (-9223372036854775808.0000000000L, "-2^63"),

    createTest (18446744073709551615.000f, "2^64-1"),
    createTest (18446744073709551615.000, "2^64-1"),
    createTest (18446744073709551615.000L, "2^64-1"),

    createTest (-18446744073709551615.000f, "-2^64-1"),
    createTest (-18446744073709551615.000, "-2^64-1"),
    createTest (-18446744073709551615.000L, "-2^64-1"),

    createTest (static_cast<float> (std::nan ("")), "float nan"),
    createTest (static_cast<double> (std::nan ("")), "double nan"),
    createTest (static_cast<long double> (std::nan ("")), "long double nan"),

    createTest (static_cast<float> (INFINITY),  "float +inf"),
    createTest (static_cast<float> (-INFINITY), "float -inf"),

    createTest (static_cast<double> (INFINITY),  "double +inf"),
    createTest (static_cast<double> (-INFINITY), "double -inf"),

    createTest (static_cast<long double> (INFINITY),  "long double +inf"),
    createTest (static_cast<long double> (-INFINITY), "long double -inf")
};

} // namespace test
コード例 #28
0
 Layer* restartAction()
 {
     return createTest(sceneIdx);
 }
コード例 #29
0
ファイル: lrh.cpp プロジェクト: MagnusJohnsson/wysiwyd
// Production
bool LRH::meaningToSentence(string meaning){
    copyPastTrainFile(scorpusFileSD.c_str(), stemporaryCorpus.c_str());
    createTest(stemporaryCorpus.c_str(), meaning);
    callReservoir(sreservoirSD, sclosed_class_wordsSD);
    return true;
}