Line data Source code
1 : #include "frontend/handlers/storage_read_internal.h"
2 :
3 : #include "backend/storage/storage.h"
4 : #include "gtest/gtest.h"
5 :
6 : namespace bigquery_emulator {
7 : namespace frontend {
8 : namespace internal {
9 : namespace {
10 :
11 1 : TEST(StorageReadInternalTest, TimestampValueToMicrosStringWireForms) {
12 1 : struct Case {
13 1 : const char* wire;
14 1 : const char* want;
15 1 : };
16 1 : static constexpr Case kCases[] = {
17 1 : {"2025-12-01 10:49:40+00", "1764586180000000"},
18 1 : {"2026-06-05 20:26:43.220623+00", "1780691203220623"},
19 1 : {"1764586180000000", "1764586180000000"},
20 1 : };
21 3 : for (const Case& c : kCases) {
22 3 : SCOPED_TRACE(c.wire);
23 3 : auto got =
24 3 : TimestampValueToMicrosString(backend::storage::Value::String(c.wire));
25 6 : ASSERT_TRUE(got.ok()) << got.status();
26 3 : EXPECT_EQ(*got, c.want);
27 3 : }
28 1 : }
29 :
30 1 : TEST(StorageReadInternalTest, TimestampValueToMicrosStringInt64Passthrough) {
31 1 : auto got = TimestampValueToMicrosString(
32 1 : backend::storage::Value::Int64(1780691203220623));
33 2 : ASSERT_TRUE(got.ok()) << got.status();
34 1 : EXPECT_EQ(*got, "1780691203220623");
35 1 : }
36 :
37 : } // namespace
38 : } // namespace internal
39 : } // namespace frontend
40 : } // namespace bigquery_emulator
|