#include #include #include #include #include #include #include #include DEFTEST(version_str) { const u32 vraw = VERSION(100,200,101,255); version_t vers = v_rawtoc(vraw); usize sz = v_ctosn_sz(vers); TEST_ASSERT(sz > 0); char verstr[sz+1]; TEST_ASSERT_EQ(v_ctosn(vers, sz+1, verstr), sz); //XXX: It appears we need to bswap the raw versions to compare them ordinally (to b-endian). const u32 vraw2 = bswap(VERSION(1,0,1,0)); TEST_ASSERT( vraw2 >= bswap(VERSION(1,0,0,0)) && vraw2 > bswap(VERSION(2,0,0,0)) ); char* verstr_h; INFO("Version: 0x%x, raw: 0x%x", vers.raw, vraw); INFO("Output is: (%lu chars)\t%s", sz, verstr); INFO("Output is (static):\t%s", v_ctoss(vers)); INFO("Output is (leak):\t\t%s", (verstr_h = v_ctos(vers))); TEST_ASSERT(verstr_h); free(verstr_h); return TEST_OK; } RUNTEST_DEBUG(version_str)