@@ -1065,6 +1065,76 @@ void Test_OS_ObjectIdIterator(void)
1065
1065
UtAssert_STUB_COUNT (OS_Unlock_Global_Impl , 2 );
1066
1066
}
1067
1067
1068
+ void Test_OS_ObjectIDInteger (void )
1069
+ {
1070
+ /*
1071
+ * Test Case For:
1072
+ * OS_ObjectIdToInteger, OS_ObjectIdFromInteger, OS_ObjectIdEqual, OS_ObjectIdDefined
1073
+ */
1074
+ int32 actual ;
1075
+ OS_object_token_t token ;
1076
+ osal_id_t typesI [OS_MAX_TOTAL_RECORDS ];
1077
+ osal_id_t typesJ [OS_MAX_TOTAL_RECORDS ];
1078
+ uint32 intID ;
1079
+ int32 recordscount = 0 ;
1080
+ osal_objtype_t idtype ;
1081
+ char str [OS_MAX_API_NAME ];
1082
+
1083
+ for (idtype = 0 ; idtype < OS_OBJECT_TYPE_USER ; ++ idtype )
1084
+ {
1085
+ actual = OS_SUCCESS ;
1086
+ while (actual == OS_SUCCESS && recordscount < OS_MAX_TOTAL_RECORDS )
1087
+ {
1088
+ snprintf (str , sizeof (str ), "%d" , (int )recordscount );
1089
+ actual = OS_ObjectIdAllocateNew (idtype , str , & token );
1090
+
1091
+ if (actual == OS_SUCCESS )
1092
+ {
1093
+ typesI [recordscount ] = token .obj_id ;
1094
+ intID = OS_ObjectIdToInteger (typesI [recordscount ]);
1095
+ typesJ [recordscount ] = OS_ObjectIdFromInteger (intID );
1096
+
1097
+ recordscount ++ ;
1098
+ }
1099
+ }
1100
+ }
1101
+
1102
+ UtAssert_True (recordscount < OS_MAX_TOTAL_RECORDS , "All Id types checked" );
1103
+
1104
+ for (int i = 0 ; i < recordscount ; i ++ )
1105
+ {
1106
+ UtAssert_True (OS_ObjectIdDefined (typesI [i ]), "%lu Is defined" , OS_ObjectIdToInteger (typesI [i ]));
1107
+
1108
+ for (int j = 0 ; j < recordscount ; j ++ )
1109
+ {
1110
+ if (i == j )
1111
+ {
1112
+ UtAssert_True (OS_ObjectIdEqual (typesI [i ], typesJ [j ]), "%lu equals %lu" , OS_ObjectIdToInteger (typesI [i ]),
1113
+ OS_ObjectIdToInteger (typesJ [j ]));
1114
+ }
1115
+ else
1116
+ {
1117
+ UtAssert_True (!OS_ObjectIdEqual (typesI [i ], typesJ [j ]), "%lu does not equal %lu" ,
1118
+ OS_ObjectIdToInteger (typesI [i ]), OS_ObjectIdToInteger (typesJ [j ]));
1119
+ }
1120
+ }
1121
+ }
1122
+ }
1123
+
1124
+ void Test_OS_ObjectIDUndefined (void )
1125
+ {
1126
+ osal_id_t id ;
1127
+ uint32 intID ;
1128
+
1129
+ UtAssert_True (!OS_ObjectIdDefined (OS_OBJECT_ID_UNDEFINED ), "%lu Is undefined" ,
1130
+ OS_ObjectIdToInteger (OS_OBJECT_ID_UNDEFINED ));
1131
+
1132
+ intID = OS_ObjectIdToInteger (OS_OBJECT_ID_UNDEFINED );
1133
+ id = OS_ObjectIdFromInteger (intID );
1134
+
1135
+ UtAssert_True (!OS_ObjectIdDefined (id ), "%lu Is undefined" , OS_ObjectIdToInteger (id ));
1136
+ }
1137
+
1068
1138
/* Osapi_Test_Setup
1069
1139
*
1070
1140
* Purpose:
@@ -1115,4 +1185,6 @@ void UtTest_Setup(void)
1115
1185
ADD_TEST (OS_GetBaseForObjectType );
1116
1186
ADD_TEST (OS_GetResourceName );
1117
1187
ADD_TEST (OS_ObjectIdIterator );
1188
+ ADD_TEST (OS_ObjectIDInteger );
1189
+ ADD_TEST (OS_ObjectIDUndefined );
1118
1190
}
0 commit comments