00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include <stdlib.h>
00041 #include <stdio.h>
00042 #include <string.h>
00043 #include <time.h>
00044
00045 #include "CUnit/Basic.h"
00046
00047 #include "ksm/ksm.h"
00048 #include "ksm/db_fields.h"
00049 #include "test_routines.h"
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 static void TestKsmParameterSet(void)
00060 {
00061 char* sql;
00062 int status;
00063 int where = 0;
00064 char buffer[2];
00065 DB_RESULT result;
00066 DB_ROW row;
00067
00068
00069 status = KsmParameterSet("Blah","Test", 2, 2);
00070 CU_ASSERT_EQUAL(status, 0);
00071
00072 sql = DqsSpecifyInit("PARAMETER_VIEW", DB_PARAMETER_VIEW_FIELDS);
00073 DqsConditionString(&sql, "NAME", DQS_COMPARE_EQ, "Blah", where++);
00074 DqsConditionString(&sql, "CATEGORY", DQS_COMPARE_EQ, "Test", where++);
00075 DqsEnd(&sql);
00076 status = DbExecuteSql(DbHandle(), sql, &result);
00077 CU_ASSERT_EQUAL(status, 0);
00078 DqsFree(sql);
00079
00080 status = DbFetchRow(result, &row);
00081 CU_ASSERT_EQUAL(status, 0);
00082 status = DbStringBuffer(row, DB_PARAMETER_VALUE, buffer, sizeof(buffer));
00083 CU_ASSERT_EQUAL(status, 0);
00084 CU_ASSERT_STRING_EQUAL(buffer, "2");
00085
00086 DbFreeRow(row);
00087 DbFreeResult(result);
00088
00089
00090 status = KsmParameterSet("Blah2", "Test", 2, 2);
00091 CU_ASSERT_EQUAL(status, 0);
00092
00093 where = 0;
00094 sql = DqsSpecifyInit("PARAMETER_VIEW", DB_PARAMETER_VIEW_FIELDS);
00095 DqsConditionString(&sql, "NAME", DQS_COMPARE_EQ, "Blah2", where++);
00096 DqsConditionString(&sql, "CATEGORY", DQS_COMPARE_EQ, "Test", where++);
00097 DqsEnd(&sql);
00098 status = DbExecuteSql(DbHandle(), sql, &result);
00099 CU_ASSERT_EQUAL(status, 0);
00100 DqsFree(sql);
00101
00102 status = DbFetchRow(result, &row);
00103 CU_ASSERT_EQUAL(status, 0);
00104 status = DbStringBuffer(row, DB_PARAMETER_VALUE, buffer, sizeof(buffer));
00105 CU_ASSERT_EQUAL(status, 0);
00106 CU_ASSERT_STRING_EQUAL(buffer, "2");
00107
00108
00109 status = KsmParameterSet("Blah3", "Test", 2, 2);
00110 CU_ASSERT_EQUAL(status, 65548);
00111
00112 DbFreeRow(row);
00113 DbFreeResult(result);
00114 }
00115
00116
00117
00118
00119
00120
00121
00122
00123 static void TestKsmParameterShow(void)
00124 {
00125 int status;
00126
00127
00128
00129
00130
00131 status = KsmParameterShow("Blah", "Test", 2);
00132 CU_ASSERT_EQUAL(status, 0);
00133
00134 }
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 int TestKsmParameter(void);
00152 int TestKsmParameter(void)
00153 {
00154 struct test_testdef tests[] = {
00155 {"KsmParameterSet", TestKsmParameterSet},
00156 {"KsmParameterShow", TestKsmParameterShow},
00157 {NULL, NULL}
00158 };
00159
00160
00161
00162
00163
00164
00165 return TcuCreateSuite("KsmParameter", TdbSetup, TdbTeardown, tests);
00166 }