Integer* AsInteger() override { return this; }
const Integer* AsInteger() const override { return this; }
uint32_t width() const { return width_; }
+ bool IsSigned() const { return signed_; }
private:
uint32_t width_; // bit width
}
}
+TEST(Types, IntSignedness) {
+ std::vector<bool> signednesses = {true, false, false, true};
+ std::vector<std::unique_ptr<Integer>> types;
+ for (bool s : signednesses) {
+ types.emplace_back(new Integer(32, s));
+ }
+ for (size_t i = 0; i < signednesses.size(); i++) {
+ EXPECT_EQ(signednesses[i], types[i]->IsSigned());
+ }
+}
+
TEST(Types, IntWidth) {
std::vector<uint32_t> widths = {1, 2, 4, 8, 16, 32, 48, 64, 128};
std::vector<std::unique_ptr<Integer>> types;