2019-06-19 13:50:58 +00:00
|
|
|
""" Unit tests for some utility functions """
|
|
|
|
|
|
|
|
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
|
2021-03-12 16:54:14 +00:00
|
|
|
|
|
|
|
# buildifier: disable=bzl-visibility
|
|
|
|
load("//foreign_cc/private:framework.bzl", "uniq_list_keep_order")
|
2019-06-19 13:50:58 +00:00
|
|
|
|
|
|
|
def _uniq_list_keep_order_test(ctx):
|
|
|
|
env = unittest.begin(ctx)
|
|
|
|
|
2020-05-04 17:50:45 +00:00
|
|
|
list = [1, 2, 3, 1, 4, 1, 2, 3, 5, 1, 2, 4, 7, 5]
|
2019-06-19 13:50:58 +00:00
|
|
|
filtered = uniq_list_keep_order(list)
|
2020-05-04 17:50:45 +00:00
|
|
|
asserts.equals(env, [1, 2, 3, 4, 5, 7], filtered)
|
2019-06-19 13:50:58 +00:00
|
|
|
|
2021-01-25 22:01:43 +00:00
|
|
|
filtered_empty = uniq_list_keep_order([])
|
|
|
|
asserts.equals(env, [], filtered_empty)
|
2019-06-19 13:50:58 +00:00
|
|
|
|
|
|
|
return unittest.end(env)
|
|
|
|
|
|
|
|
uniq_list_keep_order_test = unittest.make(_uniq_list_keep_order_test)
|
|
|
|
|
|
|
|
def utils_test_suite():
|
|
|
|
unittest.suite(
|
|
|
|
"utils_test_suite",
|
2020-05-04 17:50:45 +00:00
|
|
|
uniq_list_keep_order_test,
|
2019-06-19 13:50:58 +00:00
|
|
|
)
|