test: check that octal_mode behaves correctly

This commit is contained in:
Marcus Holland-Moritz 2024-08-03 02:02:20 +02:00
parent d3721e8e8e
commit d0d649e45a

View File

@ -20,6 +20,8 @@
*/
#include <array>
#include <optional>
#include <sstream>
#include <string_view>
#include <gtest/gtest.h>
@ -76,6 +78,20 @@ std::ostream& operator<<(std::ostream& os, octal_mode const& mode) {
#define EXPECT_EQ_MODE(a, b) EXPECT_EQ(octal_mode{a}, octal_mode{b})
TEST(chmod_transformer, octal_mode) {
std::ostringstream os;
os << octal_mode{07777};
EXPECT_EQ(os.str(), "07777 UGSrwxrwxrwx");
os.str("");
os << octal_mode{std::nullopt};
EXPECT_EQ(os.str(), "std::nullopt");
os.str("");
os << octal_mode{0644};
EXPECT_EQ(os.str(), "0644 ---rw-r--r--");
}
TEST(chmod_transformer, basic) {
{
internal::chmod_transformer ct{"u+x", 0022};