[svn-commits] dvossel: branch group/aoc r251943 - in /team/group/aoc: include/asterisk/ mai...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Mar 12 11:48:34 CST 2010


Author: dvossel
Date: Fri Mar 12 11:48:30 2010
New Revision: 251943

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=251943
Log:
additional aoc unit test checks

Modified:
    team/group/aoc/include/asterisk/aoc.h
    team/group/aoc/main/aoc.c
    team/group/aoc/tests/test_aoc.c

Modified: team/group/aoc/include/asterisk/aoc.h
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/include/asterisk/aoc.h?view=diff&rev=251943&r1=251942&r2=251943
==============================================================================
--- team/group/aoc/include/asterisk/aoc.h (original)
+++ team/group/aoc/include/asterisk/aoc.h Fri Mar 12 11:48:30 2010
@@ -133,7 +133,7 @@
 
 /* \brief Sets the type of total for a AOC-D message
  *
- * \note If this value is not set, the default for the message is TOTAL 
+ * \note If this value is not set, the default for the message is TOTAL
  *
  * \param total type, TOTAL or SUBTOTAL
  *
@@ -145,7 +145,7 @@
  *
  * \param ast_aoc_decoded struct to set values on
  * \param currency amount REQUIRED
- * \param currency multiplier REQUIRED
+ * \param currency multiplier REQUIRED, 0 or undefined value defaults to AOC_MULT_ONE.
  * \param currency name OPTIONAL
  *
  * \retval 0 success

Modified: team/group/aoc/main/aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/main/aoc.c?view=diff&rev=251943&r1=251942&r2=251943
==============================================================================
--- team/group/aoc/main/aoc.c (original)
+++ team/group/aoc/main/aoc.c Fri Mar 12 11:48:30 2010
@@ -411,6 +411,7 @@
 			encoded->flags |= AOC_ENCODED_CHARGE_FREE;
 		case AOC_CHARGE_NA:
 		default:
+			encoded->flags |= AOC_ENCODED_CHARGE_NA;
 			break;
 		}
 
@@ -474,7 +475,6 @@
 	}
 
 	return 0;
-
 }
 
 unsigned int ast_aoc_get_currency_amount(struct ast_aoc_decoded *decoded)
@@ -611,7 +611,7 @@
 		res = -1;
 	}
 
-	ast_free(new);
-	ast_free(encoded);
+	ast_aoc_destroy_decoded(new);
+	ast_aoc_destroy_encoded(encoded);
 	return res;
 }

Modified: team/group/aoc/tests/test_aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/tests/test_aoc.c?view=diff&rev=251943&r1=251942&r2=251943
==============================================================================
--- team/group/aoc/tests/test_aoc.c (original)
+++ team/group/aoc/tests/test_aoc.c Fri Mar 12 11:48:30 2010
@@ -16,12 +16,12 @@
  * at the top of the source tree.
  */
 
-/*! 
+/*!
  * \file
  * \brief Generic AOC encode decode tests
  *
- * \author David Vossel  <dvossel at digium.com>
- * 
+ * \author David Vossel <dvossel at digium.com>
+ *
  * \ingroup tests
  */
 
@@ -168,14 +168,39 @@
 
 	}
 
-	/* Add billing id information */
-	if ((ast_aoc_set_billing_id(decoded, AOC_BILLING_CALL_FWD_NO_REPLY) ||
-		(ast_aoc_get_billing_id(decoded) != AOC_BILLING_CALL_FWD_NO_REPLY))) {
-
-		ast_test_status_update(test, "TEST 2, could not set billing id correctly\n");
-		res = AST_TEST_FAIL;
-		goto cleanup_aoc_test;
-
+	/* Test every billing id possiblity */
+	{
+		int billid[9] = {
+			AOC_BILLING_NA,
+			AOC_BILLING_NORMAL,
+			AOC_BILLING_REVERSE_CHARGE,
+			AOC_BILLING_CREDIT_CARD,
+			AOC_BILLING_CALL_FWD_UNCONDITIONAL,
+			AOC_BILLING_CALL_FWD_BUSY,
+			AOC_BILLING_CALL_FWD_NO_REPLY,
+			AOC_BILLING_CALL_DEFLECTION,
+			AOC_BILLING_CALL_TRANSFER,
+		};
+		int i;
+
+		/* these should fail */
+		if (!(ast_aoc_set_billing_id(decoded, (AOC_BILLING_NA - 1))) ||
+			!(ast_aoc_set_billing_id(decoded, (AOC_BILLING_CALL_TRANSFER + 1)))) {
+
+				ast_test_status_update(test, "TEST 2, setting invalid billing id should fail\n");
+				res = AST_TEST_FAIL;
+				goto cleanup_aoc_test;
+		}
+
+		for (i = 0; i < ARRAY_LEN(billid); i++) {
+			if ((ast_aoc_set_billing_id(decoded, billid[i]) ||
+				(ast_aoc_get_billing_id(decoded) != billid[i]))) {
+
+				ast_test_status_update(test, "TEST 2, could not set billing id correctly, iteration #%d\n", i);
+				res = AST_TEST_FAIL;
+				goto cleanup_aoc_test;
+			}
+		}
 	}
 	/* Encode the message */
 	if (ast_aoc_test_encode_decode_match(decoded)) {
@@ -229,10 +254,51 @@
 	}
 	if ((decoded = ast_aoc_create(AOC_REQUEST, 0, 0))) {
 
-		ast_test_status_update(test, "Test 4: aoc-d creation with no valid charge type should fail\n");
-		res = AST_TEST_FAIL;
-		goto cleanup_aoc_test;
-	}
+		ast_test_status_update(test, "Test 4: aoc request creation with no data should have failed\n");
+		res = AST_TEST_FAIL;
+		goto cleanup_aoc_test;
+	}
+	if ((decoded = ast_aoc_create(AOC_REQUEST, -12345678, -23456789))) {
+
+		ast_test_status_update(test, "Test 4: aoc request creation with random data should have failed\n");
+		res = AST_TEST_FAIL;
+		goto cleanup_aoc_test;
+	}
+
+	/* ---- Test 5 ---- create AOC-E message with charge type == FREE and charge type == NA */
+	/* create AOC-E message */
+	if (!(decoded = ast_aoc_create(AOC_E, AOC_CHARGE_FREE, 0)) ||
+		(ast_aoc_get_msg_type(decoded) != AOC_E) ||
+		(ast_aoc_get_charge_type(decoded) != AOC_CHARGE_FREE)) {
+
+		ast_test_status_update(test, "Test 5: failed to create AOC-E message, charge type Free\n");
+		res = AST_TEST_FAIL;
+		goto cleanup_aoc_test;
+	}
+	if (ast_aoc_test_encode_decode_match(decoded)) {
+		ast_test_status_update(test, "Test5: encode decode routine did not match expected results, charge type Free\n");
+		res = AST_TEST_FAIL;
+		goto cleanup_aoc_test;
+	}
+	/* cleanup decoded msg */
+	decoded = ast_aoc_destroy_decoded(decoded);
+
+	/* create AOC-E message */
+	if (!(decoded = ast_aoc_create(AOC_E, AOC_CHARGE_NA, 0)) ||
+		(ast_aoc_get_msg_type(decoded) != AOC_E) ||
+		(ast_aoc_get_charge_type(decoded) != AOC_CHARGE_NA)) {
+
+		ast_test_status_update(test, "Test 5: failed to create AOC-E message, charge type NA\n");
+		res = AST_TEST_FAIL;
+		goto cleanup_aoc_test;
+	}
+	if (ast_aoc_test_encode_decode_match(decoded)) {
+		ast_test_status_update(test, "Test5: encode decode routine did not match expected results, charge type NA.\n");
+		res = AST_TEST_FAIL;
+		goto cleanup_aoc_test;
+	}
+	/* cleanup decoded msg */
+	decoded = ast_aoc_destroy_decoded(decoded);
 
 cleanup_aoc_test:
 




More information about the svn-commits mailing list