aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src
diff options
context:
space:
mode:
authorRemco Bloemen <remco@wicked.ventures>2018-05-28 19:07:04 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-06-08 06:38:47 +0800
commit76b918d40e3bb485cdd45149888f012d9ec2b67f (patch)
tree8a9e47b9db5ffb74e545f2dc3f39a811f0d88f01 /packages/contracts/src
parentf5bc0b205c217eac8abdfee9dcdb3c4d21b5c31e (diff)
downloaddexon-sol-tools-76b918d40e3bb485cdd45149888f012d9ec2b67f.tar
dexon-sol-tools-76b918d40e3bb485cdd45149888f012d9ec2b67f.tar.gz
dexon-sol-tools-76b918d40e3bb485cdd45149888f012d9ec2b67f.tar.bz2
dexon-sol-tools-76b918d40e3bb485cdd45149888f012d9ec2b67f.tar.lz
dexon-sol-tools-76b918d40e3bb485cdd45149888f012d9ec2b67f.tar.xz
dexon-sol-tools-76b918d40e3bb485cdd45149888f012d9ec2b67f.tar.zst
dexon-sol-tools-76b918d40e3bb485cdd45149888f012d9ec2b67f.zip
Convert Solidity tests to vectors
Diffstat (limited to 'packages/contracts/src')
-rw-r--r--packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol203
1 files changed, 0 insertions, 203 deletions
diff --git a/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol b/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol
index 18deede4c..64bc182f4 100644
--- a/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol
+++ b/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol
@@ -46,207 +46,4 @@ contract TestLibMem is
// Return modified memory contents
return mem;
}
-
- function test1()
- external
- {
- // Length of array & length to copy
- uint256 length = 0;
-
- // Create source array
- bytes memory sourceArray = new bytes(length);
-
- // Create dest array with same contents as source array
- bytes memory destArray = new bytes(length);
- memcpy(
- getMemAddress(destArray) + 32, // skip copying array length
- getMemAddress(sourceArray) + 32, // skip copying array length
- length
- );
-
- // Verify contents of source & dest arrays match
- require(
- areBytesEqual(sourceArray, destArray),
- "Test #1 failed. Array contents are not the same."
- );
- }
-
- function test2()
- external
- {
- // Length of array & length to copy
- uint256 length = 1;
-
- // Create source array
- bytes memory sourceArray = new bytes(length);
- sourceArray[0] = byte(1);
-
- // Create dest array with same contents as source array
- bytes memory destArray = new bytes(length);
- memcpy(
- getMemAddress(destArray) + 32, // skip copying array length
- getMemAddress(sourceArray) + 32, // skip copying array length
- length
- );
-
- // Verify contents of source & dest arrays match
- require(
- areBytesEqual(sourceArray, destArray),
- "Test #2 failed. Array contents are not the same."
- );
- }
-
- function test3()
- external
- {
- // Length of array & length to copy
- uint256 length = 11;
-
- // Create source array
- bytes memory sourceArray = new bytes(length);
- for(uint256 i = 0; i < length; ++i) {
- sourceArray[i] = byte((i % 0xF) + 1); // [1..f]
- }
-
- // Create dest array with same contents as source array
- bytes memory destArray = new bytes(length);
- memcpy(
- getMemAddress(destArray) + 32, // skip copying array length
- getMemAddress(sourceArray) + 32, // skip copying array length
- length
- );
-
- // Verify contents of source & dest arrays match
- require(
- areBytesEqual(sourceArray, destArray),
- "Test #3 failed. Array contents are not the same."
- );
- }
-
- function test4()
- external
- {
- // Length of array & length to copy
- uint256 length = 32;
-
- // Create source array
- bytes memory sourceArray = new bytes(length);
- for(uint256 i = 0; i < length; ++i) {
- sourceArray[i] = byte((i % 0xF) + 1); // [1..f]
- }
-
- // Create dest array with same contents as source array
- bytes memory destArray = new bytes(length);
- memcpy(
- getMemAddress(destArray) + 32, // skip copying array length
- getMemAddress(sourceArray) + 32, // skip copying array length
- length
- );
-
- // Verify contents of source & dest arrays match
- require(
- areBytesEqual(sourceArray, destArray),
- "Test #4 failed. Array contents are not the same."
- );
- }
-
- function test5()
- external
- {
- // Length of array & length to copy
- uint256 length = 72;
-
- // Create source array
- bytes memory sourceArray = new bytes(length);
- for(uint256 i = 0; i < length; ++i) {
- sourceArray[i] = byte((i % 0xF) + 1); // [1..f]
- }
-
- // Create dest array with same contents as source array
- bytes memory destArray = new bytes(length);
- memcpy(
- getMemAddress(destArray) + 32, // skip copying array length
- getMemAddress(sourceArray) + 32, // skip copying array length
- length
- );
-
- // Verify contents of source & dest arrays match
- require(
- areBytesEqual(sourceArray, destArray),
- "Test #5 failed. Array contents are not the same."
- );
- }
-
-
- function test6()
- external
- {
- // Length of arrays
- uint256 length1 = 72;
- uint256 length2 = 100;
-
- // The full source array is used for comparisons at the end
- bytes memory fullSourceArray = new bytes(length1 + length2);
-
- // First source array
- bytes memory sourceArray1 = new bytes(length1);
- for(uint256 i = 0; i < length1; ++i) {
- sourceArray1[i] = byte((i % 0xF) + 1); // [1..f]
- fullSourceArray[i] = byte((i % 0xF) + 1); // [1..f]
- }
-
- // Second source array
- bytes memory sourceArray2 = new bytes(length2);
- for(uint256 j = 0; i < length2; ++i) {
- sourceArray2[j] = byte((j % 0xF) + 1); // [1..f]
- fullSourceArray[length1+j] = byte((j % 0xF) + 1); // [1..f]
- }
-
- // Create dest array with same contents as source arrays
- bytes memory destArray = new bytes(length1 + length2);
- memcpy(
- getMemAddress(destArray) + 32, // skip copying array length
- getMemAddress(sourceArray1) + 32, // skip copying array length
- length1
- );
- memcpy(
- getMemAddress(destArray) + 32 + length1, // skip copying array length + sourceArray1 bytes
- getMemAddress(sourceArray2) + 32, // skip copying array length
- length2
- );
-
- // Verify contents of source & dest arrays match
- require(
- areBytesEqual(fullSourceArray, destArray),
- "Test #6 failed. Array contents are not the same."
- );
- }
-
- function test7()
- external
- {
- // Length of array & length to copy
- uint256 length = 72;
-
- // Create source array
- bytes memory sourceArray = new bytes(length);
- for(uint256 i = 0; i < length; ++i) {
- sourceArray[i] = byte((i % 0xF) + 1); // [1..f]
- }
-
- // Create dest array with same contents as source array
- bytes memory destArray = new bytes(length);
- memcpy(
- getMemAddress(destArray) + 32, // skip copying array length
- getMemAddress(sourceArray) + 32, // skip copying array length
- length - 8 // Copy all but last byte.
- );
-
- // Verify contents of source & dest arrays match
- // We expect this to fail
- require(
- areBytesEqual(sourceArray, destArray),
- "Test #7 failed. Array contents are not the same. This is expected."
- );
- }
}