-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_paste.zig.zig
More file actions
144 lines (115 loc) · 4.81 KB
/
Copy pathtest_paste.zig.zig
File metadata and controls
144 lines (115 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const std = @import("std");
const parser = @import("src/parser.zig");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const json =
\\{"main":{"temp":25.17,"feels_like":25.02,"pressure":1016,"humidity":49},"weather":[{"description":"clear sky"}],"wind":{"speed":1.34},"clouds":{"all":10}}
;
const parsed = try parser.parseWeather(allocator, json);
defer parsed.deinit();
const out = std.io.getStdOut().writer();
try out.print("Temp: {d:.1f}°C\n", .{parsed.data.temp});
try out.print("Condition: {s}\n", .{parsed.data.condition});
}
EOF
# Compile and run the test
zig build-exe test_parse.zig --dep parser -Mroot=test_parse.zig -Mparser=src/parser.zig
./test_parse# Create a test file
cat > test_parse.zig << 'EOF'
const std = @import("std");
const parser = @import("src/parser.zig");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const json =
\\{"main":{"temp":25.17,"feels_like":25.02,"pressure":1016,"humidity":49},"weather":[{"description":"clear sky"}],"wind":{"speed":1.34},"clouds":{"all":10}}
;
const parsed = try parser.parseWeather(allocator, json);
defer parsed.deinit();
const out = std.io.getStdOut().writer();
try out.print("Temp: {d:.1f}°C\n", .{parsed.data.temp});
try out.print("Condition: {s}\n", .{parsed.data.condition});
}
EOF
# Compile and run the test
zig build-exe test_parse.zig --dep parser -Mroot=test_parse.zig -Mparser=src/parser.zig
./test_parse# Create a test file
cat > test_parse.zig << 'EOF'
const std = @import("std");
const parser = @import("src/parser.zig");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const json =
\\{"main":{"temp":25.17,"feels_like":25.02,"pressure":1016,"humidity":49},"weather":[{"description":"clear sky"}],"wind":{"speed":1.34},"clouds":{"all":10}}
;
const parsed = try parser.parseWeather(allocator, json);
defer parsed.deinit();
const out = std.io.getStdOut().writer();
try out.print("Temp: {d:.1f}°C\n", .{parsed.data.temp});
try out.print("Condition: {s}\n", .{parsed.data.condition});
}
EOF
# Compile and run the test
zig build-exe test_parse.zig --dep parser -Mroot=test_parse.zig -Mparser=src/parser.zig
./test_parse# Create a test file
cat > test_parse.zig << 'EOF'
const std = @import("std");
const parser = @import("src/parser.zig");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const json =
\\{"main":{"temp":25.17,"feels_like":25.02,"pressure":1016,"humidity":49},"weather":[{"description":"clear sky"}],"wind":{"speed":1.34},"clouds":{"all":10}}
;
const parsed = try parser.parseWeather(allocator, json);
defer parsed.deinit();
const out = std.io.getStdOut().writer();
try out.print("Temp: {d:.1f}°C\n", .{parsed.data.temp});
try out.print("Condition: {s}\n", .{parsed.data.condition});
}
EOF
# Compile and run the test
zig build-exe test_parse.zig --dep parser -Mroot=test_parse.zig -Mparser=src/parser.zig
./test_parse# Create a test file
cat > test_parse.zig << 'EOF'
const std = @import("std");
const parser = @import("src/parser.zig");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const json =
\\{"main":{"temp":25.17,"feels_like":25.02,"pressure":1016,"humidity":49},"weather":[{"description":"clear sky"}],"wind":{"speed":1.34},"clouds":{"all":10}}
;
const parsed = try parser.parseWeather(allocator, json);
defer parsed.deinit();
const out = std.io.getStdOut().writer();
try out.print("Temp: {d:.1f}°C\n", .{parsed.data.temp});
try out.print("Condition: {s}\n", .{parsed.data.condition});
}
EOF
# Compile and run the test
zig build-exe test_parse.zig --dep parser -Mroot=test_parse.zig -Mparser=src/parser.zig
./test_parse# Create a test file
cat > test_parse.zig << 'EOF'
const std = @import("std");
const parser = @import("src/parser.zig");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const json =
\\{"main":{"temp":25.17,"feels_like":25.02,"pressure":1016,"humidity":49},"weather":[{"description":"clear sky"}],"wind":{"speed":1.34},"clouds":{"all":10}}
;
const parsed = try parser.parseWeather(allocator, json);
defer parsed.deinit();
const out = std.io.getStdOut().writer();
try out.print("Temp: {d:.1f}°C\n", .{parsed.data.temp});
try out.print("Condition: {s}\n", .{parsed.data.condition});
}