Skip to content

Commit

Permalink
Replace column/table test utilities with macros (#12242)
Browse files Browse the repository at this point in the history
Authors:
  - Yunsong Wang (https://github.com/PointKernel)

Approvers:
  - David Wendt (https://github.com/davidwendt)
  - Bradley Dice (https://github.com/bdice)

URL: #12242
  • Loading branch information
PointKernel authored Nov 29, 2022
1 parent 2a5411a commit 9af3ed8
Show file tree
Hide file tree
Showing 22 changed files with 275 additions and 284 deletions.
64 changes: 33 additions & 31 deletions cpp/include/cudf_test/column_utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
#include <thrust/host_vector.h>
#include <thrust/iterator/transform_iterator.h>

namespace cudf {
namespace test {
namespace cudf::test {

/**
* @brief Verbosity level of output from column and table comparison functions.
Expand All @@ -42,6 +41,8 @@ enum class debug_output_level {

constexpr size_type default_ulp = 4;

namespace detail {

/**
* @brief Verifies the property equality of two columns.
*
Expand Down Expand Up @@ -107,13 +108,6 @@ bool expect_columns_equivalent(cudf::column_view const& lhs,
debug_output_level verbosity = debug_output_level::FIRST_ERROR,
size_type fp_ulps = cudf::test::default_ulp);

/**
* @brief Verifies the given column is empty
*
* @param col The column to check
*/
void expect_column_empty(cudf::column_view const& col);

/**
* @brief Verifies the bitwise equality of two device memory buffers.
*
Expand All @@ -123,6 +117,15 @@ void expect_column_empty(cudf::column_view const& col);
*/
void expect_equal_buffers(void const* lhs, void const* rhs, std::size_t size_bytes);

} // namespace detail

/**
* @brief Verifies the given column is empty
*
* @param col The column to check
*/
void expect_column_empty(cudf::column_view const& col);

/**
* @brief Formats a column view as a string
*
Expand Down Expand Up @@ -260,36 +263,35 @@ inline std::pair<thrust::host_vector<std::string>, std::vector<bitmask_type>> to
return {host_data, bitmask_to_host(c)};
}

} // namespace test
} // namespace cudf
} // namespace cudf::test

// Macros for showing line of failure.
#define CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUAL(lhs, rhs) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::expect_column_properties_equal(lhs, rhs); \
} while (0)

#define CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUIVALENT(lhs, rhs) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::expect_column_properties_equivalent(lhs, rhs); \
#define CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUAL(lhs, rhs) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::detail::expect_column_properties_equal(lhs, rhs); \
} while (0)

#define CUDF_TEST_EXPECT_COLUMNS_EQUAL(lhs, rhs...) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::expect_columns_equal(lhs, rhs); \
#define CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUIVALENT(lhs, rhs) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::detail::expect_column_properties_equivalent(lhs, rhs); \
} while (0)

#define CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(lhs, rhs...) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::expect_columns_equivalent(lhs, rhs); \
#define CUDF_TEST_EXPECT_COLUMNS_EQUAL(lhs, rhs...) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::detail::expect_columns_equal(lhs, rhs); \
} while (0)

#define CUDF_TEST_EXPECT_EQUAL_BUFFERS(lhs, rhs, size_bytes) \
#define CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(lhs, rhs...) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::expect_equal_buffers(lhs, rhs, size_bytes); \
cudf::test::detail::expect_columns_equivalent(lhs, rhs); \
} while (0)

#define CUDF_TEST_EXPECT_EQUAL_BUFFERS(lhs, rhs, size_bytes) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::detail::expect_equal_buffers(lhs, rhs, size_bytes); \
} while (0)
32 changes: 15 additions & 17 deletions cpp/include/cudf_test/table_utilities.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020, NVIDIA CORPORATION.
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,8 +19,7 @@
#include <cudf/table/table_view.hpp>
#include <cudf/types.hpp>

namespace cudf {
namespace test {
namespace cudf::test::detail {
/**
* @brief Verifies the property equality of two tables.
*
Expand Down Expand Up @@ -50,24 +49,23 @@ void expect_tables_equal(cudf::table_view lhs, cudf::table_view rhs);
*/
void expect_tables_equivalent(cudf::table_view lhs, cudf::table_view rhs);

} // namespace test
} // namespace cudf
} // namespace cudf::test::detail

// Macros for showing line of failure.
#define CUDF_TEST_EXPECT_TABLE_PROPERTIES_EQUAL(lhs, rhs) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::expect_table_properties_equal(lhs, rhs); \
#define CUDF_TEST_EXPECT_TABLE_PROPERTIES_EQUAL(lhs, rhs) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::detail::expect_table_properties_equal(lhs, rhs); \
} while (0)

#define CUDF_TEST_EXPECT_TABLES_EQUAL(lhs, rhs) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::expect_tables_equal(lhs, rhs); \
#define CUDF_TEST_EXPECT_TABLES_EQUAL(lhs, rhs) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::detail::expect_tables_equal(lhs, rhs); \
} while (0)

#define CUDF_TEST_EXPECT_TABLES_EQUIVALENT(lhs, rhs) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::expect_tables_equivalent(lhs, rhs); \
#define CUDF_TEST_EXPECT_TABLES_EQUIVALENT(lhs, rhs) \
do { \
SCOPED_TRACE(" <-- line of failure\n"); \
cudf::test::detail::expect_tables_equivalent(lhs, rhs); \
} while (0)
Loading

0 comments on commit 9af3ed8

Please sign in to comment.