diff --git a/tests/test_npy2hls.py b/tests/test_npy2hls.py
index e205c06f31e9773a16c3decbd21a314fcbd4b8dc..ea54d900a8e3a06b53cb4074072b15747c6c598c 100644
--- a/tests/test_npy2hls.py
+++ b/tests/test_npy2hls.py
@@ -1,5 +1,6 @@
 import numpy as np
 
+from finn.backend.fpgadataflow.utils import numpy_to_hls_code
 from finn.core.datatype import DataType
 from finn.core.utils import array2hexstring, pack_innermost_dim_as_hex_string
 
@@ -23,3 +24,20 @@ def test_pack_innermost_dim_as_hex_string():
     B = [[[3, 3], [3, 3]], [[1, 3], [3, 1]]]
     eB = np.asarray([["0f", "0f"], ["07", "0d"]])
     assert (pack_innermost_dim_as_hex_string(B, DataType.UINT2, 8) == eB).all()
+
+
+def test_numpy_to_hls_code():
+    def remove_all_whitespace(s):
+        return "".join(s.split())
+
+    A = [[1, 1, 1, 0], [0, 1, 1, 0]]
+    ret = numpy_to_hls_code(A, DataType.BINARY, "test", True)
+    eA = """ap_uint<4> test[2] =
+    {ap_uint<4>("e", 16), ap_uint<4>("6", 16)};"""
+    assert remove_all_whitespace(ret) == remove_all_whitespace(eA)
+    B = [[[3, 3], [3, 3]], [[1, 3], [3, 1]]]
+    ret = numpy_to_hls_code(B, DataType.UINT2, "test", True)
+    eB = """ap_uint<4> test[2][2] =
+    {{ap_uint<4>("f", 16), ap_uint<4>("f", 16)},
+     {ap_uint<4>("7", 16), ap_uint<4>("d", 16)}};"""
+    assert remove_all_whitespace(ret) == remove_all_whitespace(eB)