<commit_before>/*******************************************************
 * Copyright (c) 2014, ArrayFire
 * All rights reserved.
 *
 * This file is distributed under 3-clause BSD license.
 * The complete license agreement can be obtained at:
 * http://arrayfire.com/licenses/BSD-3-Clause
 ********************************************************/

#include <gtest/gtest.h>
#include <af/array.h>
#include <af/arith.h>
#include <af/data.h>
#include <testHelpers.hpp>

template<typename T>
class Compare : public ::testing::Test
{
};

typedef ::testing::Types<float, double, uint, int, intl, uintl, uchar, short, ushort> TestTypes;
TYPED_TEST_CASE(Compare, TestTypes);

#define COMPARE(OP, Name)                                       \
    TYPED_TEST(Compare, Test_##Name)                            \
    {                                                           \
        typedef TypeParam T;                                    \
        const int num = 1 << 20;                                \
        af_dtype ty = (af_dtype) af::dtype_traits<T>::af_type;  \
        af::array a = af::randu(num, ty);                       \
        af::array b = af::randu(num, ty);                       \
        af::array c = a OP b;                                   \
        std::vector<T> ha(num), hb(num);                        \
        std::vector<char> hc(num);                              \
        a.host(&ha[0]);                                         \
        b.host(&hb[0]);                                         \
        c.host(&hc[0]);                                         \
        for (int i = 0; i < num; i++) {                         \
            char res = ha[i] OP hb[i];                          \
            ASSERT_EQ((int)res, (int)hc[i]);                    \
        }                                                       \
    }                                                           \

COMPARE(==, eq)
COMPARE(!=, ne)
COMPARE(<=, le)
COMPARE(>=, ge)
COMPARE(<, lt)
COMPARE(>, gt)<commit_msg>Skip double tests when double precision not supported<commit_after>/*******************************************************
 * Copyright (c) 2014, ArrayFire
 * All rights reserved.
 *
 * This file is distributed under 3-clause BSD license.
 * The complete license agreement can be obtained at:
 * http://arrayfire.com/licenses/BSD-3-Clause
 ********************************************************/

#include <gtest/gtest.h>
#include <af/array.h>
#include <af/arith.h>
#include <af/data.h>
#include <testHelpers.hpp>

template<typename T>
class Compare : public ::testing::Test
{
};

typedef ::testing::Types<float, double, uint, int, intl, uintl, uchar, short, ushort> TestTypes;
TYPED_TEST_CASE(Compare, TestTypes);

#define COMPARE(OP, Name)                                       \
    TYPED_TEST(Compare, Test_##Name)                            \
    {                                                           \
        typedef TypeParam T;                                    \
        if (noDoubleTests<T>()) return;                         \
        const int num = 1 << 20;                                \
        af_dtype ty = (af_dtype) af::dtype_traits<T>::af_type;  \
        af::array a = af::randu(num, ty);                       \
        af::array b = af::randu(num, ty);                       \
        af::array c = a OP b;                                   \
        std::vector<T> ha(num), hb(num);                        \
        std::vector<char> hc(num);                              \
        a.host(&ha[0]);                                         \
        b.host(&hb[0]);                                         \
        c.host(&hc[0]);                                         \
        for (int i = 0; i < num; i++) {                         \
            char res = ha[i] OP hb[i];                          \
            ASSERT_EQ((int)res, (int)hc[i]);                    \
        }                                                       \
    }                                                           \

COMPARE(==, eq)
COMPARE(!=, ne)
COMPARE(<=, le)
COMPARE(>=, ge)
COMPARE(<, lt)
COMPARE(>, gt)
{'fraction_non_alphanumeric': 0.16971153846153847, 'fraction_numerical': 0.00625, 'mean_word_length': 1.0878073256397391, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2708856', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1053, 'n_words': 245}