Download data/test.jsonl from SalutefaceAAC/unit-test-edge-cases: direct link, hf CLI and curl.
- Browser
- Download file 22.3 kB
-
https://huggingface.co/datasets/SalutefaceAAC/unit-test-edge-cases/resolve/main/data/test.jsonl
- Command line
-
hf download hf://datasets/SalutefaceAAC/unit-test-edge-cases/data/test.jsonl
-
curl -L -o test.jsonl https://huggingface.co/datasets/SalutefaceAAC/unit-test-edge-cases/resolve/main/data/test.jsonl
22.3 kB
| {"id": "f376f75f331474967c220fb30cad3024", "language": "python", "function_name": "gcd", "function_code": "def gcd(a: int, b: int) -> int:\n while b:\n a, b = b, a % b\n return a", "edge_case_type": "zero_second", "edge_case_description": "gcd(a, 0) returns a", "test_framework": "pytest", "unit_test": "def test_gcd_zero_second():\n assert gcd(12, 0) == 12", "difficulty": "medium"} | |
| {"id": "1bd729fd3d817f278aa19978d469b3f5", "language": "go", "function_name": "Clamp", "function_code": "func Clamp(value, lo, hi float64) float64 {\n\tif value < lo {\n\t\treturn lo\n\t}\n\tif value > hi {\n\t\treturn hi\n\t}\n\treturn value\n}", "edge_case_type": "within", "edge_case_description": "value within range returns unchanged", "test_framework": "testing", "unit_test": "func TestClampWithin(t *testing.T) {\n\tif got := Clamp(5, 0, 10); got != 5 {\n\t\tt.Errorf(\"expected 5, got %v\", got)\n\t}\n}", "difficulty": "medium"} | |
| {"id": "c38115808054b91838da744f06c4d376", "language": "python", "function_name": "zip_with", "function_code": "def zip_with(fn, a: list, b: list) -> list:\n \"\"\"Apply fn element-wise to paired elements of a and b.\"\"\"\n return [fn(x, y) for x, y in zip(a, b)]", "edge_case_type": "unequal_length", "edge_case_description": "shorter list determines output length (zip truncates)", "test_framework": "pytest", "unit_test": "def test_zip_with_unequal():\n assert zip_with(lambda x, y: x * y, [1, 2, 3], [4, 5]) == [4, 10]", "difficulty": "medium"} | |
| {"id": "8cd68ea1326668254fe054b48c46cf00", "language": "python", "function_name": "Stack", "function_code": "class Stack:\n def __init__(self):\n self._data = []\n\n def push(self, item):\n self._data.append(item)\n\n def pop(self):\n if not self._data:\n raise IndexError(\"pop from empty stack\")\n return self._data.pop()\n\n def peek(self):\n if not self._data:\n raise IndexError(\"peek at empty stack\")\n return self._data[-1]\n\n def is_empty(self):\n return len(self._data) == 0\n\n def size(self):\n return len(self._data)", "edge_case_type": "peek_does_not_remove", "edge_case_description": "peek does not remove the top element", "test_framework": "pytest", "unit_test": "def test_stack_peek_no_remove():\n s = Stack()\n s.push(99)\n assert s.peek() == 99\n assert s.size() == 1", "difficulty": "medium"} | |
| {"id": "c76b17d7dc1151df0e35a2d5dac1bd59", "language": "python", "function_name": "reverse_string", "function_code": "def reverse_string(s: str) -> str:\n return s[::-1]", "edge_case_type": "empty_string", "edge_case_description": "reversing empty string returns empty string", "test_framework": "pytest", "unit_test": "def test_reverse_empty():\n assert reverse_string(\"\") == \"\"", "difficulty": "easy"} | |
| {"id": "ff6761be44545c17f67d6fe8205f7c37", "language": "javascript", "function_name": "chunk", "function_code": "function chunk(arr, size) {\n if (size <= 0) throw new Error('size must be positive');\n const result = [];\n for (let i = 0; i < arr.length; i += size) {\n result.push(arr.slice(i, i + size));\n }\n return result;\n}", "edge_case_type": "size_larger", "edge_case_description": "chunk size larger than array returns one chunk", "test_framework": "jest", "unit_test": "test(\"chunk size larger\", () => {\n expect(chunk([1, 2], 10)).toEqual([[1, 2]]);\n});", "difficulty": "easy"} | |
| {"id": "376458901f4615d8964bef1fcdd0c92e", "language": "python", "function_name": "string_to_int", "function_code": "def string_to_int(s: str) -> int | None:\n \"\"\"Parse s as integer, returning None on failure.\"\"\"\n try:\n return int(s.strip())\n except (ValueError, AttributeError):\n return None", "edge_case_type": "large_number", "edge_case_description": "very large integer string parsed correctly", "test_framework": "pytest", "unit_test": "def test_str2int_large():\n assert string_to_int('999999999999') == 999999999999", "difficulty": "medium"} | |
| {"id": "0a51c3a0594d864e06c8d95d748cef37", "language": "python", "function_name": "group_consecutive", "function_code": "def group_consecutive(nums: list[int]) -> list[list[int]]:\n \"\"\"Group consecutive integers into sublists.\"\"\"\n if not nums:\n return []\n groups, current = [[nums[0]]], [nums[0]]\n for n in nums[1:]:\n if n == current[-1] + 1:\n current.append(n)\n else:\n groups.append([n])\n current = groups[-1]\n return groups", "edge_case_type": "single", "edge_case_description": "single element forms one group", "test_framework": "pytest", "unit_test": "def test_group_consec_single():\n assert group_consecutive([5]) == [[5]]", "difficulty": "easy"} | |
| {"id": "cb7d4accfa2c28aa00b0c34f28b964b6", "language": "java", "function_name": "wordCount", "function_code": "public static Map<String, Integer> wordCount(String text) {\n Map<String, Integer> counts = new HashMap<>();\n if (text == null || text.isBlank()) return counts;\n for (String word : text.toLowerCase().split(\"\\\\s+\")) {\n counts.merge(word, 1, Integer::sum);\n }\n return counts;\n}", "edge_case_type": "blank_string", "edge_case_description": "blank string returns empty map", "test_framework": "junit4", "unit_test": "@Test\npublic void testWordCountBlank() {\n assertTrue(wordCount(\" \").isEmpty());\n}", "difficulty": "medium"} | |
| {"id": "e7ca80362f30924ed8e66400fd4283bb", "language": "typescript", "function_name": "deepEqual", "function_code": "export function deepEqual(a: unknown, b: unknown): boolean {\n return JSON.stringify(a) === JSON.stringify(b);\n}", "edge_case_type": "primitive_equal", "edge_case_description": "same primitives are equal", "test_framework": "jest", "unit_test": "test('deepEqual primitives', () => {\n expect(deepEqual(1, 1)).toBe(true);\n expect(deepEqual('a', 'a')).toBe(true);\n});", "difficulty": "medium"} | |
| {"id": "6137a4eda7bf2ca2a9c5eca136431e42", "language": "python", "function_name": "deep_get", "function_code": "def deep_get(d: dict, *keys, default=None):\n for key in keys:\n if not isinstance(d, dict):\n return default\n d = d.get(key, default)\n return d", "edge_case_type": "empty_dict", "edge_case_description": "empty dict returns default", "test_framework": "pytest", "unit_test": "def test_deep_get_empty():\n assert deep_get({}, \"key\") is None", "difficulty": "easy"} | |
| {"id": "b7f2950749e0aeae7089f08dd32fe20c", "language": "python", "function_name": "fizzbuzz", "function_code": "def fizzbuzz(n: int) -> str:\n if n % 15 == 0:\n return \"FizzBuzz\"\n if n % 3 == 0:\n return \"Fizz\"\n if n % 5 == 0:\n return \"Buzz\"\n return str(n)", "edge_case_type": "thirty", "edge_case_description": "30 is divisible by both 3 and 5", "test_framework": "pytest", "unit_test": "def test_fizzbuzz_thirty():\n assert fizzbuzz(30) == \"FizzBuzz\"", "difficulty": "medium"} | |
| {"id": "4108f69ca6894883cec4a59836af7694", "language": "rust", "function_name": "median", "function_code": "pub fn median(mut nums: Vec<f64>) -> Option<f64> {\n if nums.is_empty() { return None; }\n nums.sort_by(|a, b| a.partial_cmp(b).unwrap());\n let mid = nums.len() / 2;\n if nums.len() % 2 == 1 {\n Some(nums[mid])\n } else {\n Some((nums[mid - 1] + nums[mid]) / 2.0)\n }\n}", "edge_case_type": "odd_count", "edge_case_description": "odd number of elements returns middle", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_median_odd() {\n assert_eq!(median(vec![1.0, 3.0, 5.0]), Some(3.0));\n}", "difficulty": "medium"} | |
| {"id": "c703abbe75c4b32390db40532b5106ae", "language": "javascript", "function_name": "groupBy", "function_code": "function groupBy(arr, key) {\n return arr.reduce((acc, item) => {\n const k = item[key];\n if (!acc[k]) acc[k] = [];\n acc[k].push(item);\n return acc;\n }, {});\n}", "edge_case_type": "empty_array", "edge_case_description": "grouping empty array returns empty object", "test_framework": "jest", "unit_test": "test(\"groupBy empty\", () => {\n expect(groupBy([], \"type\")).toEqual({});\n});", "difficulty": "easy"} | |
| {"id": "55afb6f49a212ba62e184ed9f36bb012", "language": "python", "function_name": "celsius_to_fahrenheit", "function_code": "def celsius_to_fahrenheit(c: float) -> float:\n return c * 9 / 5 + 32", "edge_case_type": "body_temperature", "edge_case_description": "37\u00b0C equals 98.6\u00b0F", "test_framework": "pytest", "unit_test": "def test_celsius_body_temp():\n assert abs(celsius_to_fahrenheit(37) - 98.6) < 0.01", "difficulty": "medium"} | |
| {"id": "19435f90fc13801d3ffc298f56f7e028", "language": "python", "function_name": "is_palindrome", "function_code": "def is_palindrome(s: str) -> bool:\n s = s.lower().replace(\" \", \"\")\n return s == s[::-1]", "edge_case_type": "single_char", "edge_case_description": "single character is always a palindrome", "test_framework": "pytest", "unit_test": "def test_is_palindrome_single():\n assert is_palindrome(\"a\") is True", "difficulty": "easy"} | |
| {"id": "caf0f73df6e8603d6d1888746336cb23", "language": "python", "function_name": "levenshtein", "function_code": "def levenshtein(s: str, t: str) -> int:\n \"\"\"Compute Levenshtein (edit) distance between s and t.\"\"\"\n m, n = len(s), len(t)\n dp = list(range(n + 1))\n for i in range(1, m + 1):\n prev = dp[0]\n dp[0] = i\n for j in range(1, n + 1):\n tmp = dp[j]\n if s[i-1] == t[j-1]:\n dp[j] = prev\n else:\n dp[j] = 1 + min(prev, dp[j], dp[j-1])\n prev = tmp\n return dp[n]", "edge_case_type": "both_empty", "edge_case_description": "both empty strings have distance 0", "test_framework": "pytest", "unit_test": "def test_lev_both_empty():\n assert levenshtein(\"\", \"\") == 0", "difficulty": "easy"} | |
| {"id": "bd05d26653ddc47dc73467a02862d7f0", "language": "javascript", "function_name": "pipe", "function_code": "function pipe(...fns) {\n return (x) => fns.reduce((v, f) => f(v), x);\n}", "edge_case_type": "multiple_fns", "edge_case_description": "pipe applies functions left to right", "test_framework": "jest", "unit_test": "test(\"pipe multiple fns\", () => {\n const fn = pipe(x => x + 1, x => x * 2);\n expect(fn(3)).toBe(8);\n});", "difficulty": "medium"} | |
| {"id": "e9d7b6c6417accd1e2050714dbabf5ce", "language": "python", "function_name": "is_prime", "function_code": "def is_prime(n: int) -> bool:\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True", "edge_case_type": "two", "edge_case_description": "2 is the smallest prime", "test_framework": "pytest", "unit_test": "def test_is_prime_two():\n assert is_prime(2) is True", "difficulty": "medium"} | |
| {"id": "86438f9029ce0d6c410dcec732baa913", "language": "python", "function_name": "group_consecutive", "function_code": "def group_consecutive(nums: list[int]) -> list[list[int]]:\n \"\"\"Group consecutive integers into sublists.\"\"\"\n if not nums:\n return []\n groups, current = [[nums[0]]], [nums[0]]\n for n in nums[1:]:\n if n == current[-1] + 1:\n current.append(n)\n else:\n groups.append([n])\n current = groups[-1]\n return groups", "edge_case_type": "no_consecutive", "edge_case_description": "no consecutive pairs yields single-element groups", "test_framework": "pytest", "unit_test": "def test_group_consec_none():\n assert group_consecutive([1, 3, 5]) == [[1], [3], [5]]", "difficulty": "medium"} | |
| {"id": "dad124db74358d63d1d42d3780bf318c", "language": "python", "function_name": "find_max", "function_code": "def find_max(nums: list[int]) -> int:\n if not nums:\n raise ValueError(\"List must not be empty\")\n return max(nums)", "edge_case_type": "all_negative", "edge_case_description": "list of all negative numbers returns least negative", "test_framework": "pytest", "unit_test": "def test_find_max_all_negative():\n assert find_max([-3, -1, -7]) == -1", "difficulty": "medium"} | |
| {"id": "2ae162fa1e487b722abf3f7c8393a7e7", "language": "go", "function_name": "Contains", "function_code": "func Contains(slice []string, target string) bool {\n\tfor _, v := range slice {\n\t\tif v == target {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "edge_case_type": "empty_slice", "edge_case_description": "empty slice returns false", "test_framework": "testing", "unit_test": "func TestContainsEmpty(t *testing.T) {\n\tif Contains([]string{}, \"x\") {\n\t\tt.Error(\"expected false for empty slice\")\n\t}\n}", "difficulty": "easy"} | |
| {"id": "66b2e44c8f9e860a34b561f27022ea20", "language": "python", "function_name": "gcd", "function_code": "def gcd(a: int, b: int) -> int:\n while b:\n a, b = b, a % b\n return a", "edge_case_type": "equal_values", "edge_case_description": "gcd of equal values returns that value", "test_framework": "pytest", "unit_test": "def test_gcd_equal():\n assert gcd(7, 7) == 7", "difficulty": "medium"} | |
| {"id": "feccd00b77b0ac978c37de2a336a4d9b", "language": "python", "function_name": "merge_sorted", "function_code": "def merge_sorted(a: list[int], b: list[int]) -> list[int]:\n \"\"\"Merge two sorted lists into one sorted list.\"\"\"\n result, i, j = [], 0, 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i]); i += 1\n else:\n result.append(b[j]); j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result", "edge_case_type": "second_empty", "edge_case_description": "merging empty second list returns copy of first", "test_framework": "pytest", "unit_test": "def test_merge_second_empty():\n assert merge_sorted([1, 2, 3], []) == [1, 2, 3]", "difficulty": "easy"} | |
| {"id": "55918343d3dae5c7dbf95198aa789a4f", "language": "typescript", "function_name": "pick", "function_code": "export function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {\n const result = {} as Pick<T, K>;\n for (const k of keys) {\n if (k in obj) result[k] = obj[k];\n }\n return result;\n}", "edge_case_type": "empty_keys", "edge_case_description": "picking no keys returns empty object", "test_framework": "jest", "unit_test": "test('pick empty keys', () => {\n expect(pick({a:1,b:2}, [])).toEqual({});\n});", "difficulty": "easy"} | |
| {"id": "5543bdcac99870a1196e64d775a63ecb", "language": "rust", "function_name": "median", "function_code": "pub fn median(mut nums: Vec<f64>) -> Option<f64> {\n if nums.is_empty() { return None; }\n nums.sort_by(|a, b| a.partial_cmp(b).unwrap());\n let mid = nums.len() / 2;\n if nums.len() % 2 == 1 {\n Some(nums[mid])\n } else {\n Some((nums[mid - 1] + nums[mid]) / 2.0)\n }\n}", "edge_case_type": "even_count", "edge_case_description": "even number of elements returns average of two middle", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_median_even() {\n assert_eq!(median(vec![1.0, 2.0, 3.0, 4.0]), Some(2.5));\n}", "difficulty": "medium"} | |
| {"id": "0e9f04e0ae8e73824206fec6b36c3b75", "language": "python", "function_name": "Stack", "function_code": "class Stack:\n def __init__(self):\n self._data = []\n\n def push(self, item):\n self._data.append(item)\n\n def pop(self):\n if not self._data:\n raise IndexError(\"pop from empty stack\")\n return self._data.pop()\n\n def peek(self):\n if not self._data:\n raise IndexError(\"peek at empty stack\")\n return self._data[-1]\n\n def is_empty(self):\n return len(self._data) == 0\n\n def size(self):\n return len(self._data)", "edge_case_type": "push_none", "edge_case_description": "None can be pushed and popped correctly", "test_framework": "pytest", "unit_test": "def test_stack_push_none():\n s = Stack()\n s.push(None)\n assert s.pop() is None", "difficulty": "medium"} | |
| {"id": "b64e1b2f26645bf88c1d88073a2939a1", "language": "go", "function_name": "Clamp", "function_code": "func Clamp(value, lo, hi float64) float64 {\n\tif value < lo {\n\t\treturn lo\n\t}\n\tif value > hi {\n\t\treturn hi\n\t}\n\treturn value\n}", "edge_case_type": "at_lo", "edge_case_description": "value at lo returns lo", "test_framework": "testing", "unit_test": "func TestClampAtLo(t *testing.T) {\n\tif got := Clamp(0, 0, 10); got != 0 {\n\t\tt.Errorf(\"expected 0, got %v\", got)\n\t}\n}", "difficulty": "easy"} | |
| {"id": "3975219d0e3a96e86d67b31733af7d10", "language": "rust", "function_name": "is_prime", "function_code": "pub fn is_prime(n: u64) -> bool {\n if n < 2 { return false; }\n if n == 2 { return true; }\n if n % 2 == 0 { return false; }\n let mut i = 3u64;\n while i * i <= n {\n if n % i == 0 { return false; }\n i += 2;\n }\n true\n}", "edge_case_type": "composite", "edge_case_description": "9 is not prime", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_prime_composite() {\n assert!(!is_prime(9));\n}", "difficulty": "easy"} | |
| {"id": "a9772a786446f147f037c085784d1330", "language": "python", "function_name": "binary_search", "function_code": "def binary_search(arr: list[int], target: int) -> int:\n lo, hi = 0, len(arr) - 1\n while lo <= hi:\n mid = (lo + hi) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n lo = mid + 1\n else:\n hi = mid - 1\n return -1", "edge_case_type": "single_element_found", "edge_case_description": "single-element array with matching target returns 0", "test_framework": "pytest", "unit_test": "def test_binary_search_single_found():\n assert binary_search([7], 7) == 0", "difficulty": "medium"} | |
| {"id": "b7b3ed95266ec5eb71ad3ba8ce7e1d7f", "language": "java", "function_name": "findMax", "function_code": "public static int findMax(int[] arr) {\n if (arr.length == 0) throw new IllegalArgumentException(\"Array is empty\");\n int max = arr[0];\n for (int v : arr) if (v > max) max = v;\n return max;\n}", "edge_case_type": "all_negative", "edge_case_description": "all negative values returns least negative", "test_framework": "junit4", "unit_test": "@Test\npublic void testFindMaxAllNegative() {\n assertEquals(-1, findMax(new int[]{-5, -1, -9}));\n}", "difficulty": "medium"} | |
| {"id": "08c5056331e15081705917e07a9686ec", "language": "java", "function_name": "clamp", "function_code": "public static double clamp(double value, double lo, double hi) {\n return Math.max(lo, Math.min(hi, value));\n}", "edge_case_type": "at_boundary", "edge_case_description": "value exactly at lo boundary", "test_framework": "junit4", "unit_test": "@Test\npublic void testClampAtLo() {\n assertEquals(0.0, clamp(0, 0, 10), 1e-9);\n}", "difficulty": "easy"} | |
| {"id": "240abf57fd2fc3832a87eae90878e353", "language": "rust", "function_name": "is_prime", "function_code": "pub fn is_prime(n: u64) -> bool {\n if n < 2 { return false; }\n if n == 2 { return true; }\n if n % 2 == 0 { return false; }\n let mut i = 3u64;\n while i * i <= n {\n if n % i == 0 { return false; }\n i += 2;\n }\n true\n}", "edge_case_type": "large_prime", "edge_case_description": "97 is prime", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_prime_large() {\n assert!(is_prime(97));\n}", "difficulty": "medium"} | |
| {"id": "33857628021df6ebae4b34eaa2463100", "language": "python", "function_name": "fizzbuzz", "function_code": "def fizzbuzz(n: int) -> str:\n if n % 15 == 0:\n return \"FizzBuzz\"\n if n % 3 == 0:\n return \"Fizz\"\n if n % 5 == 0:\n return \"Buzz\"\n return str(n)", "edge_case_type": "one", "edge_case_description": "1 is not divisible by 3 or 5", "test_framework": "pytest", "unit_test": "def test_fizzbuzz_one():\n assert fizzbuzz(1) == \"1\"", "difficulty": "easy"} | |
| {"id": "a21d477e4ae3143d66a6bae35b3644bb", "language": "python", "function_name": "levenshtein", "function_code": "def levenshtein(s: str, t: str) -> int:\n \"\"\"Compute Levenshtein (edit) distance between s and t.\"\"\"\n m, n = len(s), len(t)\n dp = list(range(n + 1))\n for i in range(1, m + 1):\n prev = dp[0]\n dp[0] = i\n for j in range(1, n + 1):\n tmp = dp[j]\n if s[i-1] == t[j-1]:\n dp[j] = prev\n else:\n dp[j] = 1 + min(prev, dp[j], dp[j-1])\n prev = tmp\n return dp[n]", "edge_case_type": "commutative", "edge_case_description": "levenshtein distance is symmetric", "test_framework": "pytest", "unit_test": "def test_lev_commutative():\n assert levenshtein(\"kitten\", \"sitting\") == levenshtein(\"sitting\", \"kitten\")", "difficulty": "hard"} | |
| {"id": "429b13545b775fe39a8c8d4d762e8b93", "language": "go", "function_name": "Divide", "function_code": "func Divide(a, b float64) (float64, error) {\n\tif b == 0 {\n\t\treturn 0, errors.New(\"division by zero\")\n\t}\n\treturn a / b, nil\n}", "edge_case_type": "zero_divisor", "edge_case_description": "b=0 returns error", "test_framework": "testing", "unit_test": "func TestDivideZero(t *testing.T) {\n\t_, err := Divide(10, 0)\n\tif err == nil {\n\t\tt.Error(\"expected error for zero divisor\")\n\t}\n}", "difficulty": "medium"} | |
| {"id": "c3c64c1c9f64ded03bcccf7d7a33dc96", "language": "java", "function_name": "clamp", "function_code": "public static double clamp(double value, double lo, double hi) {\n return Math.max(lo, Math.min(hi, value));\n}", "edge_case_type": "below", "edge_case_description": "value below lo returns lo", "test_framework": "junit4", "unit_test": "@Test\npublic void testClampBelow() {\n assertEquals(0.0, clamp(-5, 0, 10), 1e-9);\n}", "difficulty": "medium"} | |
| {"id": "e9233d1c4c2d85401588b6015877eb29", "language": "python", "function_name": "count_vowels", "function_code": "def count_vowels(s: str) -> int:\n return sum(1 for c in s.lower() if c in \"aeiou\")", "edge_case_type": "mixed_case", "edge_case_description": "mixed case string counts all vowels", "test_framework": "pytest", "unit_test": "def test_count_vowels_mixed():\n assert count_vowels(\"Hello World\") == 3", "difficulty": "medium"} | |