MCPcopy Create free account
hub / github.com/apache/fory / test_ints

Function test_ints

python/pyfory/format/tests/test_encoder.py:143–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

141
142
143def test_ints():
144 cls = pyfory.record_class_factory("TestNumeric", ["f" + str(i) for i in range(1, 9)])
145 s = schema(
146 [
147 field("f1", int64()),
148 field("f2", int64()),
149 field("f3", int32()),
150 field("f4", int32()),
151 field("f5", int16()),
152 field("f6", int16()),
153 field("f7", int8()),
154 field("f8", int8()),
155 ]
156 )
157 print("pyfory.cls", pyfory.get_qualified_classname(cls))
158 obj = cls(
159 f1=2**63 - 1,
160 f2=-(2**63),
161 f3=2**31 - 1,
162 f4=-(2**31),
163 f5=2**15 - 1,
164 f6=-(2**15),
165 f7=2**7 - 1,
166 f8=-(2**7),
167 )
168 print("obj", obj)
169 encoder = pyfory.create_row_encoder(s)
170 row = encoder.to_row(obj)
171 print("row", row)
172 new_obj = encoder.from_row(row)
173 print("new_obj", new_obj)
174 assert new_obj.f1 == obj.f1
175 assert new_obj.f2 == obj.f2
176 assert new_obj.f3 == obj.f3
177 assert new_obj.f4 == obj.f4
178 assert new_obj.f5 == obj.f5
179 assert new_obj.f6 == obj.f6
180 assert new_obj.f7 == obj.f7
181 assert new_obj.f8 == obj.f8
182
183
184def test_basic():

Callers

nothing calls this directly

Calls 8

schemaFunction · 0.85
from_rowMethod · 0.80
fieldFunction · 0.50
int64Function · 0.50
int32Function · 0.50
int16Function · 0.50
int8Function · 0.50
to_rowMethod · 0.45

Tested by

no test coverage detected