// test Point_decode() // #include #include #include "impl.h" static struct { char *estr, *xstr; int r; // r is expected Point_decode() return value } table[] = { // estr and e are little-endian, xstr and x are big-endian { "0000000000000000000000000000000000000000000000000000000000000000", // 0 "2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0", // sqrt(-1) 0 }, { "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", // m-1 "0000000000000000000000000000000000000000000000000000000000000000", // 0 0 }, { "ebffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", // m-2 "0000000000000000000000000000000000000000000000000000000000000000", // undefined 2 }, { "eaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", // m-3 "68febfd42613608ef448af58b1ef28311c0d964bdd30bc07fef6e61f01ae05e2", 0 }, { "e9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", // m-4, x_0=1 "461721fdd7bc15bebcb6dfffe7938bcfc76b9b9b2012bb2bd20c79f4065ba5bf", 0 }, { "e9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", // m-4, x_0=0 "39e8de022843ea4143492000186c743038946464dfed44d42df3860bf9a45a2e", 0 }, { "e8ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", // m-5 "57aff1011be28eefd5ecc8591c2f739afed342ba1824922f2b2f4072bfefa2a2", 0 }, { "e7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", // m-6 "61aca558adbb11b7c524375ea96dd2736eb6fe53643d33e22d3851b749ca8846", 0 }, { "e6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", // m-7 "0000000000000000000000000000000000000000000000000000000000000000", // undefined 2 }, { 0, 0, 0 } }, *T = table; int main( void) { E e; C x; Point p; int r; while( T->estr) { convert_E( e, T->estr); // printf( "estr = %s\n", T->estr); print_E( "e", e, M); convert( x, T->xstr); // printf( "xstr = %s\n", T->xstr); r = Point_decode( &p, e); printf( "r = %d, expected r = %d\n", r, T->r); print( " x", x, N); print( "p.x", p.x, N); print( "p.y", p.y, N); if( r != T->r || (r == 0 && memcmp( x, p.x, sizeof(x)) != 0)) printf( "fail\n"); else printf( "pass\n"); ++T; } return 0; }