예제 #1
0
    void
    test_lhs_zero ()
    {
        testcase ("lhs zero");

        test_lhs_zero(-7);
        test_lhs_zero(0);
        test_lhs_zero(32);
    }
/*
** xFilter - Initialize a cursor to point at the start of its data.
*/
static int fts3auxFilterMethod(
  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */
  int idxNum,                     /* Strategy index */
  const char *idxStr,             /* Unused */
  int nVal,                       /* Number of elements in apVal */
  sqlite3_value **apVal           /* Arguments for the indexing scheme */
){
  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;
  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;
  int rc;
  int isScan;

  UNUSED_PARAMETER(nVal);
  UNUSED_PARAMETER(idxStr);

  assert( idxStr==0 );
  assert( idxNum==FTS4AUX_EQ_CONSTRAINT || idxNum==0
       || idxNum==FTS4AUX_LE_CONSTRAINT || idxNum==FTS4AUX_GE_CONSTRAINT
       || idxNum==(FTS4AUX_LE_CONSTRAINT|FTS4AUX_GE_CONSTRAINT)
  );
  isScan = (idxNum!=FTS4AUX_EQ_CONSTRAINT);

  /* In case this cursor is being reused, close and zero it. */
  testcase(pCsr->filter.zTerm);
  sqlite3Fts3SegReaderFinish(&pCsr->csr);
  sqlite3_free((void *)pCsr->filter.zTerm);
  sqlite3_free(pCsr->aStat);
  memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);

  pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
  if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;

  if( idxNum&(FTS4AUX_EQ_CONSTRAINT|FTS4AUX_GE_CONSTRAINT) ){
    const unsigned char *zStr = sqlite3_value_text(apVal[0]);
    if( zStr ){
      pCsr->filter.zTerm = sqlite3_mprintf("%s", zStr);
      pCsr->filter.nTerm = sqlite3_value_bytes(apVal[0]);
      if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;
    }
  }
  if( idxNum&FTS4AUX_LE_CONSTRAINT ){
    int iIdx = (idxNum&FTS4AUX_GE_CONSTRAINT) ? 1 : 0;
    pCsr->zStop = sqlite3_mprintf("%s", sqlite3_value_text(apVal[iIdx]));
    pCsr->nStop = sqlite3_value_bytes(apVal[iIdx]);
    if( pCsr->zStop==0 ) return SQLITE_NOMEM;
  }

  rc = sqlite3Fts3SegReaderCursor(pFts3, 0, FTS3_SEGCURSOR_ALL,
      pCsr->filter.zTerm, pCsr->filter.nTerm, 0, isScan, &pCsr->csr
  );
  if( rc==SQLITE_OK ){
    rc = sqlite3Fts3SegReaderStart(pFts3, &pCsr->csr, &pCsr->filter);
  }

  if( rc==SQLITE_OK ) rc = fts3auxNextMethod(pCursor);
  return rc;
}
예제 #3
0
    void testEndpoint ()
    {
        testcase ("Endpoint");

        {
            std::pair <Endpoint, bool> result (
                Endpoint::from_string_checked ("1.2.3.4"));
            expect (result.second);
            if (expect (result.first.address().is_v4 ()))
            {
                expect (result.first.address().to_v4() ==
                    AddressV4 (1, 2, 3, 4));
                expect (result.first.port() == 0);
                expect (to_string (result.first) == "1.2.3.4");
            }
        }

        {
            std::pair <Endpoint, bool> result (
                Endpoint::from_string_checked ("1.2.3.4:5"));
            expect (result.second);
            if (expect (result.first.address().is_v4 ()))
            {
                expect (result.first.address().to_v4() ==
                    AddressV4 (1, 2, 3, 4));
                expect (result.first.port() == 5);
                expect (to_string (result.first) == "1.2.3.4:5");
            }
        }

        Endpoint ep;

        ep = Endpoint (AddressV4 (127,0,0,1), 80);
        expect (! is_unspecified (ep));
        expect (! is_public (ep));
        expect (  is_private (ep));
        expect (! is_multicast (ep));
        expect (  is_loopback (ep));
        expect (to_string (ep) == "127.0.0.1:80");

        ep = Endpoint (AddressV4 (10,0,0,1));
        expect (AddressV4::get_class (ep.to_v4()) == 'A');
        expect (! is_unspecified (ep));
        expect (! is_public (ep));
        expect (  is_private (ep));
        expect (! is_multicast (ep));
        expect (! is_loopback (ep));
        expect (to_string (ep) == "10.0.0.1");

        ep = Endpoint (AddressV4 (166,78,151,147));
        expect (! is_unspecified (ep));
        expect (  is_public (ep));
        expect (! is_private (ep));
        expect (! is_multicast (ep));
        expect (! is_loopback (ep));
        expect (to_string (ep) == "166.78.151.147");
    }
예제 #4
0
 void
 test_containers()
 {
     testcase ("containers");
     check_container <detail::test_hardened_unordered_set>();
     check_container <detail::test_hardened_unordered_map>();
     check_container <detail::test_hardened_unordered_multiset>();
     check_container <detail::test_hardened_unordered_multimap>();
 }
예제 #5
0
파일: func.c 프로젝트: blingstorm/sqlcipher
/*
** The zeroblob(N) function returns a zero-filled blob of size N bytes.
*/
static void zeroblobFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  i64 n;
  sqlite3 *db = sqlite3_context_db_handle(context);
  assert( argc==1 );
  UNUSED_PARAMETER(argc);
  n = sqlite3_value_int64(argv[0]);
  testcase( n==db->aLimit[SQLITE_LIMIT_LENGTH] );
  testcase( n==db->aLimit[SQLITE_LIMIT_LENGTH]+1 );
  if( n>db->aLimit[SQLITE_LIMIT_LENGTH] ){
    sqlite3_result_error_toobig(context);
  }else{
    sqlite3_result_zeroblob(context, (int)n); /* IMP: R-00293-64994 */
  }
}
예제 #6
0
int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
  int rc;
  if( pExpr==0 ) return WRC_Continue;
  testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
  testcase( ExprHasProperty(pExpr, EP_Reduced) );
  rc = pWalker->xExprCallback(pWalker, pExpr);
  if( rc==WRC_Continue
              && !ExprHasAnyProperty(pExpr,EP_TokenOnly) ){
    if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
    if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
    if( ExprHasProperty(pExpr, EP_xIsSelect) ){
      if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
    }else{
      if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
    }
  }
  return rc & WRC_Abort;
}
예제 #7
0
파일: 58.c 프로젝트: wj32/Judge
int main(int argc, char *argv[])
{
    int i;
    
    for (i = 0; i < 10; i++)
        testcase();
    
    return 0;
}
예제 #8
0
/*
** Allocate and return a pointer to an expression to load the column iCol
** from datasource iSrc in SrcList pSrc.
*/
Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){
  Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);
  if( p ){
    struct SrcList_item *pItem = &pSrc->a[iSrc];
    p->pTab = pItem->pTab;
    p->iTable = pItem->iCursor;
    if( p->pTab->iPKey==iCol ){
      p->iColumn = -1;
    }else{
      p->iColumn = (ynVar)iCol;
      testcase( iCol==BMS );
      testcase( iCol==BMS-1 );
      pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);
    }
    ExprSetProperty(p, EP_Resolved);
  }
  return p;
}
예제 #9
0
    void
    test_rhs_zero ()
    {
        testcase ("rhs zero");

        test_rhs_zero(-4);
        test_rhs_zero(0);
        test_rhs_zero(64);
    }
예제 #10
0
void check_err(Complexf* a,int*n,MPI_Comm c_comm){
  int nprocs, procid;
  MPI_Comm_rank(c_comm, &procid);
  MPI_Comm_size(c_comm,&nprocs);
  long long int size=n[0];
  size*=n[1]; size*=n[2];
  float pi=M_PI;

  int istart[3], isize[3], osize[3],ostart[3];
  accfft_local_size_dft_c2cf(n,isize,istart,osize,ostart,c_comm);

  float err=0,norm=0;

  float X,Y,Z,numerical_r,numerical_c;
  long int ptr;
  int thid=omp_get_thread_num();
  for (int i=0; i<isize[0]; i++){
    for (int j=0; j<isize[1]; j++){
      for (int k=0; k<isize[2]; k++){
        X=2*pi/n[0]*(i+istart[0]);
        Y=2*pi/n[1]*(j+istart[1]);
        Z=2*pi/n[2]*k;
        ptr=i*isize[1]*n[2]+j*n[2]+k;
        numerical_r=a[ptr][0]/size; if(numerical_r!=numerical_r) numerical_r=0;
        numerical_c=a[ptr][1]/size; if(numerical_c!=numerical_c) numerical_c=0;
        err+=std::abs(numerical_r-testcase(X,Y,Z))+std::abs(numerical_c-testcase(X,Y,Z));
        norm+=std::abs(testcase(X,Y,Z));

      }
    }
  }

  float g_err=0,g_norm=0;
  MPI_Reduce(&err,&g_err,1, MPI_FLOAT, MPI_SUM,0, MPI_COMM_WORLD);
  MPI_Reduce(&norm,&g_norm,1, MPI_FLOAT, MPI_SUM,0, MPI_COMM_WORLD);
  PCOUT<<"\nL1 Error of iFF(a)-a: "<<g_err<<std::endl;
  PCOUT<<"Relative L1 Error of iFF(a)-a: "<<g_err/g_norm<<std::endl;
  if (g_err/g_norm< 1e-5)
    PCOUT<<"\nResults are CORRECT! (upto single precision)\n\n";
  else
    PCOUT<<"\nResults are NOT CORRECT!\n\n";

  return;
} // end check_err
예제 #11
0
    void run ()
    {
        TagInt1 const zero (0);
        TagInt1 const one (1);

        testcase ("Comparison Operators");

        expect (zero >= zero, "Should be greater than or equal");
        expect (zero == zero, "Should be equal");

        expect (one > zero, "Should be greater");
        expect (one >= zero, "Should be greater than or equal");
        expect (one != zero, "Should not be equal");

        unexpected (one < zero, "Should be greater");
        unexpected (one <= zero, "Should not be greater than or equal");
        unexpected (one == zero, "Should not be equal");

        testcase ("Arithmetic Operators");

        TagInt1 tmp;

        tmp = zero + 0u;
        expect (tmp == zero, "Should be equal");

        tmp = 1u + zero;
        expect (tmp == one, "Should be equal");

        expect(--tmp == zero, "Should be equal");
        expect(tmp++ == zero, "Should be equal");
        expect(tmp == one, "Should be equal");

        expect(tmp-- == one, "Should be equal");
        expect(tmp == zero, "Should be equal");
        expect(++tmp == one, "Should be equal");

        tmp = zero;

        tmp += 1u;
        expect(tmp == one, "Should be equal");

        tmp -= 1u;
        expect(tmp == zero, "Should be equal");
    }
예제 #12
0
    void testConversionUnderflows ()
    {
        testcase ("conversion underflows");

        tryBadConvert <std::uint32_t> ("-1");

        tryBadConvert <std::int64_t> ("-99999999999999999999");
        tryBadConvert <std::int32_t> ("-4294967300");
        tryBadConvert <std::int16_t> ("-75821");
    }
예제 #13
0
 void testPassphrase()
 {
     testcase ("generation from passphrase");
     BEAST_EXPECT(testPassphrase ("masterpassphrase") ==
                  "snoPBrXtMeMyMHUVTgbuqAfg1SUTb");
     BEAST_EXPECT(testPassphrase ("Non-Random Passphrase") ==
                  "snMKnVku798EnBwUfxeSD8953sLYA");
     BEAST_EXPECT(testPassphrase ("cookies excitement hand public") ==
                  "sspUXGrmjQhq6mgc24jiRuevZiwKT");
 }
예제 #14
0
    void testAddress ()
    {
        testcase ("Address");

        std::pair <Address, bool> result (
            Address::from_string ("1.2.3.4"));
        expect (result.second);
        if (expect (result.first.is_v4 ()))
            expect (result.first.to_v4() == AddressV4 (1, 2, 3, 4));
    }
예제 #15
0
    void testKeySize ()
    {
        testcase ("Key Sizes");

        RsaSha256 f1;
        BEAST_EXPECT (!f1.sign (longKey, makeSlice (knownMessage)));

        RsaSha256 f2;
        BEAST_EXPECT (!f2.sign (shortKey, makeSlice (knownMessage)));
    }
예제 #16
0
/*
** Allocate or return the aggregate context for a user function.  A new
** context is allocated on the first call.  Subsequent calls return the
** same context that was returned on prior calls.
*/
void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
  assert( p && p->pFunc && p->pFunc->xStep );
  assert( sqlite3_mutex_held(p->pOut->db->mutex) );
  testcase( nByte<0 );
  if( (p->pMem->flags & MEM_Agg)==0 ){
    return createAggContext(p, nByte);
  }else{
    return (void*)p->pMem->z;
  }
}
예제 #17
0
int main(int argc, char** args)
{
	hashTable = (char**)malloc(MAX_SIZE*sizeof(char**));

	int t;
	scanf("%d\n", &t);
	while(t-->0)
		testcase();

	return 0;
}
예제 #18
0
int main(void) {
	int testcase_count = 0;
	scanf("%d",&testcase_count);
	
	int i = 0, j =0;
	for ( i=0; i< testcase_count; i++) {
		testcase();
	}
	
	return 0;
}
예제 #19
0
END_TEST

START_TEST (test_case2)
{
    char * retout;
    char testbuf[][10] = {"XX","II"};
    char *resultbuf = "XXII";
    retout = testcase(testbuf,resultbuf);

    fail_unless ( !strcmp(retout,resultbuf), "test case2 error!!" );
}
예제 #20
0
END_TEST

START_TEST (test_case4)
{
    char * retout;
    char testbuf[][10] = {"D","D"};
    char *resultbuf = "M";
    retout = testcase(testbuf,resultbuf);

    fail_unless ( !strcmp(retout,resultbuf), "test case4 error!!" );
}
예제 #21
0
 void testPathologies()
 {
     testcase("pathologies");
     try
     {
         lexicalCastThrow<int>("\xef\xbc\x91\xef\xbc\x90"); // utf-8 encoded
     }
     catch(BadLexicalCast const&)
     {
         pass();
     }
 }
예제 #22
0
    void testValues ()
    {
        testcase ("comparison");

        expect (from_version (1,2) == from_version (1,2));
        expect (from_version (3,4) >= from_version (3,4));
        expect (from_version (5,6) <= from_version (5,6));
        expect (from_version (7,8) >  from_version (6,7));
        expect (from_version (7,8) <  from_version (8,9));
        expect (from_version (65535,0) <  from_version (65535,65535));
        expect (from_version (65535,65535) >= from_version (65535,65535));
    }
예제 #23
0
    void run()
    {
        testcase ("Currency");
        testUnsigned <Currency> ();

        testcase ("Account");
        testUnsigned <Account> ();

        // ---

        testcase ("Issue");
        testIssueType <Issue> ();

        testcase ("IssueRef");
        testIssueType <IssueRef> ();

        testIssueSets ();
        testIssueMaps ();

        // ---

        testcase ("Book");
        testBook <Book> ();

        testcase ("BookRef");
        testBook <BookRef> ();

        testBookSets ();
        testBookMaps ();
    }
예제 #24
0
int main(int argc, char *argv)
{
	char *output;

	testcase("Setting a course for SB-01 ok?");
	testcase("SB-02 is thataway!");
	testcase("sb-01 and SB-02 and sb-03 are being attacked!");
	testcase("SB-21 and SB-42");
	testcase("Setting a course for WG-01 ok?");
	testcase("WG-02 is thataway!");
	testcase("WG-01 and WG-02 and WG-03 are being attacked!");
	testcase("WG-25 and WG-26");
	return 0;
}
예제 #25
0
    void testStringVersion ()
    {
        testcase ("string version");

        for (std::uint16_t major = 0; major < 8; major++)
        {
            for (std::uint16_t minor = 0; minor < 8; minor++)
            {
                expect (to_string (from_version (major, minor)) ==
                    std::to_string (major) + "." + std::to_string (minor));
            }
        }
    }
예제 #26
0
    void testCompare ()
    {
        testcase ("comparisons");

        checkLess ("1.0.0-alpha", "1.0.0-alpha.1");
        checkLess ("1.0.0-alpha.1", "1.0.0-alpha.beta");
        checkLess ("1.0.0-alpha.beta", "1.0.0-beta");
        checkLess ("1.0.0-beta", "1.0.0-beta.2");
        checkLess ("1.0.0-beta.2", "1.0.0-beta.11");
        checkLess ("1.0.0-beta.11", "1.0.0-rc.1");
        checkLess ("1.0.0-rc.1", "1.0.0");
        checkLess ("0.9.9", "1.0.0");
    }
예제 #27
0
    void testRandom()
    {
        testcase ("random generation");

        for (int i = 0; i < 32; i++)
        {
            auto const seed1 = randomSeed ();
            auto const seed2 = parseBase58<Seed>(toBase58(seed1));

            BEAST_EXPECT(static_cast<bool>(seed2));
            BEAST_EXPECT(equal (seed1, *seed2));
        }
    }
예제 #28
0
    void run ()
    {
        testcase ("Seed");
        RippleAddress seed;
        expect (seed.setSeedGeneric ("masterpassphrase"));
        expect (seed.humanSeed () == "snoPBrXtMeMyMHUVTgbuqAfg1SUTb", seed.humanSeed ());

        testcase ("RipplePublicKey");
        RippleAddress deprecatedPublicKey (RippleAddress::createNodePublic (seed));
        expect (deprecatedPublicKey.humanNodePublic () ==
            "n94a1u4jAz288pZLtw6yFWVbi89YamiC6JBXPVUj5zmExe5fTVg9",
                deprecatedPublicKey.humanNodePublic ());
        RipplePublicKey publicKey = deprecatedPublicKey.toPublicKey();
        expect (publicKey.to_string() == deprecatedPublicKey.humanNodePublic(),
            publicKey.to_string());

        testcase ("Generator");
        RippleAddress generator (RippleAddress::createGeneratorPublic (seed));
        expect (generator.humanGenerator () ==
            "fhuJKrhSDzV2SkjLn9qbwm5AaRmrxDPfFsHDCP6yfDZWcxDFz4mt",
                generator.humanGenerator ());
    }
예제 #29
0
/*
** If the memory cell contains a string value that must be freed by
** invoking an external callback, free it now. Calling this function
** does not free any Mem.zMalloc buffer.
*/
void sqlite3VdbeMemReleaseExternal(Mem *p){
  assert( p->db==0 || sqlite3_mutex_held(p->db->mutex) );
  testcase( p->flags & MEM_Agg );
  testcase( p->flags & MEM_Dyn );
  testcase( p->flags & MEM_RowSet );
  testcase( p->flags & MEM_Frame );
  if( p->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame) ){
    if( p->flags&MEM_Agg ){
      sqlite3VdbeMemFinalize(p, p->u.pDef);
      assert( (p->flags & MEM_Agg)==0 );
      sqlite3VdbeMemRelease(p);
    }else if( p->flags&MEM_Dyn && p->xDel ){
      assert( (p->flags&MEM_RowSet)==0 );
      p->xDel((void *)p->z);
      p->xDel = 0;
    }else if( p->flags&MEM_RowSet ){
      sqlite3RowSetClear(p->u.pRowSet);
    }else if( p->flags&MEM_Frame ){
      sqlite3VdbeMemSetNull(p);
    }
  }
}
예제 #30
0
파일: mem1.c 프로젝트: 0xr0ot/sqlcipher
/*
** Like malloc(), but remember the size of the allocation
** so that we can find it later using sqlite3MemSize().
**
** For this low-level routine, we are guaranteed that nByte>0 because
** cases of nByte<=0 will be intercepted and dealt with by higher level
** routines.
*/
static void *sqlite3MemMalloc(int nByte){
#ifdef SQLITE_MALLOCSIZE
  void *p = SQLITE_MALLOC( nByte );
  if( p==0 ){
    testcase( sqlite3GlobalConfig.xLog!=0 );
    sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte);
  }
  return p;
#else
  sqlite3_int64 *p;
  assert( nByte>0 );
  nByte = ROUND8(nByte);
  p = SQLITE_MALLOC( nByte+8 );
  if( p ){
    p[0] = nByte;
    p++;
  }else{
    testcase( sqlite3GlobalConfig.xLog!=0 );
    sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte);
  }
  return (void *)p;
#endif
}