?? mf_timeex.c
字號:
/*============================================================================* * MF_Time C Unit Tests and Examples *============================================================================*/#undef __FUNC__#define __FUNC__ "MF_TimeEx"#include "MF.h"#include "MF_BasicUtil.h"#include "MF_Time.h"#define START_DAYS 5#define START_SECS 43200#define STOP_DAYS 12#define STOP_SECS 1200#define DAY_INC 2#define SEC_INC 1000#define SEC_OVER_SID 100000int main(int argc, char **argv){ MF_Bool isLater; int retDays, retSecs; double retRealDays; MF_Time startTime, stopTime, retTime; printf("==================================================\n"); printf("MF_Time C Unit Tests and Examples\n"); printf("==================================================\n"); startTime = MF_TimeNewIS(START_DAYS, START_SECS); stopTime = MF_TimeNewIS(STOP_DAYS, STOP_SECS); retTime = MF_TimeNewUndefined(); MF_TimeGetIS(startTime, &retDays, &retSecs); printf("Ret days %d, Ret secs %d\n", retDays, retSecs); MF_ERROR_TEST(((retDays == START_DAYS) && (retSecs == START_SECS)), "MF_TimeNewIS, MF_TimeGetIS: create time and get attributes"); MF_TimeGetDays(startTime, &retRealDays); printf("Ret real days %f\n", retRealDays); MF_ERROR_TEST((MF_EQUAL(retRealDays, 5.5)), "MF_TimeGetDays: get time value as real days"); MF_TimeIncrementIS(startTime, retTime, DAY_INC, SEC_INC); MF_TimeGetIS(retTime, &retDays, &retSecs); printf("Ret days = %d, Ret secs = %d\n", retDays, retSecs); MF_ERROR_TEST(((retDays==7) && (retSecs==44200)), "MF_TimeIncrementIS: increment time, sec inc < 86400"); MF_TimeDiff(startTime, stopTime, retTime, &isLater); MF_TimeGetIS(retTime, &retDays, &retSecs); printf("Ret days = %d, Ret secs = %d\n", retDays, retSecs); MF_ERROR_TEST(((retDays == 6) && (retSecs == 44400) && (isLater == MF_TRUE)), "MF_TimeDiff: take time difference, isLater is true"); MF_TimeDiff(stopTime, startTime, retTime, &isLater); MF_TimeGetIS(retTime, &retDays, &retSecs); printf("Ret days = %d, Ret secs = %d\n", retDays, retSecs); MF_ERROR_TEST(((retDays == 6) && (retSecs == 44400) && (isLater == MF_FALSE)), "MF_TimeDiff: take time difference, isLater is false"); MF_TimeSetIS(retTime, DAY_INC, SEC_OVER_SID); MF_TimeGetIS(retTime, &retDays, &retSecs); printf("Ret days = %d, Ret secs = %d\n", retDays, retSecs); MF_ERROR_TEST(((retDays==3) && (retSecs==13600)), "MF_TimeSetIS: set time, sec > 86400"); MF_TimeDecrementIS(stopTime, retTime, DAY_INC, SEC_OVER_SID); MF_TimeGetIS(retTime, &retDays, &retSecs); printf("Ret days = %d, Ret secs = %d\n", retDays, retSecs); MF_ERROR_TEST(((retDays==8) && (retSecs==74000)), "MF_TimeDecrementIS: decrement time, sec > 86400"); MF_TimeSetIS(retTime, 0, 3600); MF_TimeDecrementIS(retTime, retTime, 0, 3600); MF_TimeGetIS(retTime, &retDays, &retSecs); printf("Ret days = %d, Ret secs = %d\n", retDays, retSecs); MF_ERROR_TEST(((retDays==0) && (retSecs==0)), "MF_TimeDecrementIS: decrement time down to 0"); printf("\nTest Print Method\n"); MF_TimePrint(startTime); MF_TimeDelete(startTime); MF_TimeDelete(stopTime); MF_TimeDelete(retTime); return(MF_SUCCESS);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -