#include <gtest/gtest.h>
#include <solution/303.h>

class NumArrayTest : public ::testing::Test
{
  protected:
    NumArray *numArray = nullptr;

    void SetUp() override
    {
        int init[] = {-2, 0, 3, -5, 2, -1};
        numArray = numArrayCreate(init, sizeof(init) / sizeof(int));
        ASSERT_NE(numArray, nullptr); // 确保初始化成功
    }

    void TearDown() override
    {
        numArrayFree(numArray);
    }
};

// 示例测试：sumRange(0, 2) == 1
TEST_F(NumArrayTest, SumRange_0_2)
{
    EXPECT_EQ(numArraySumRange(numArray, 0, 2), 1);
}

// 示例测试：sumRange(2, 5) == -1
TEST_F(NumArrayTest, SumRange_2_5)
{
    EXPECT_EQ(numArraySumRange(numArray, 2, 5), -1);
}

// 示例测试：sumRange(0, 5) == -3
TEST_F(NumArrayTest, SumRange_0_5)
{
    EXPECT_EQ(numArraySumRange(numArray, 0, 5), -3);
}