CCBigNum CCBigNum::operator-(uint32_t b) const { CCStatus status = kCCSuccess; CCBigNumRef result = CCCreateBigNum(&status); RELEASE_ASSERT(!status); status = CCBigNumSubI(result, m_number, b); RELEASE_ASSERT(!status); return result; }
static int testAddSubI() { CCStatus status; char *hex1 = "1002030405060708090021222324252627282920"; char *result = "1002030405060708090021222324252627282921"; CCBigNumRef num1 = CCBigNumFromHexString(&status, hex1); CCBigNumRef output = CCCreateBigNum(&status); CCBigNumRef resultExpected = CCBigNumFromHexString(&status, result); status = CCBigNumAddI(output, num1, 1); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, resultExpected) == 0, "expected operation result"); status = CCBigNumSubI(output, output, 1); ok(status == 0, "operation completed"); ok(CCBigNumCompare(output, num1) == 0, "expected operation result"); CCBigNumFree(num1); CCBigNumFree(output); CCBigNumFree(resultExpected); return 0; }