etk/test/testPermissions.cpp

87 lines
2.9 KiB
C++
Raw Permalink Normal View History

2018-08-31 21:43:16 +02:00
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
#include <etest/etest.hpp>
#include <test-debug/debug.hpp>
2018-09-13 23:16:14 +02:00
#include <etk/path/Permissions.hpp>
2018-08-31 21:43:16 +02:00
TEST(TestPermission, defaultContructor) {
2018-09-13 23:16:14 +02:00
etk::path::Permissions permission;
2018-08-31 21:43:16 +02:00
EXPECT_EQ(permission.isUserReadable(), false);
EXPECT_EQ(permission.isUserWritable(), false);
EXPECT_EQ(permission.isUserRunable(), false);
EXPECT_EQ(permission.isGroupReadable(), false);
EXPECT_EQ(permission.isGroupWritable(), false);
EXPECT_EQ(permission.isGroupRunable(), false);
EXPECT_EQ(permission.isOtherReadable(), false);
EXPECT_EQ(permission.isOtherWritable(), false);
EXPECT_EQ(permission.isOtherRunable(), false);
EXPECT_EQ(permission.getRight(), "---------");
}
TEST(TestPermission, fullright) {
2018-09-13 23:16:14 +02:00
etk::path::Permissions permission(0777);
2018-08-31 21:43:16 +02:00
EXPECT_EQ(permission.isUserReadable(), true);
EXPECT_EQ(permission.isUserWritable(), true);
EXPECT_EQ(permission.isUserRunable(), true);
EXPECT_EQ(permission.isGroupReadable(), true);
EXPECT_EQ(permission.isGroupWritable(), true);
EXPECT_EQ(permission.isGroupRunable(), true);
EXPECT_EQ(permission.isOtherReadable(), true);
EXPECT_EQ(permission.isOtherWritable(), true);
EXPECT_EQ(permission.isOtherRunable(), true);
EXPECT_EQ(permission.getRight(), "rwxrwxrwx");
}
TEST(TestPermission, user) {
2018-09-13 23:16:14 +02:00
etk::path::Permissions permission(0700);
2018-08-31 21:43:16 +02:00
EXPECT_EQ(permission.isUserReadable(), true);
EXPECT_EQ(permission.isUserWritable(), true);
EXPECT_EQ(permission.isUserRunable(), true);
EXPECT_EQ(permission.isGroupReadable(), false);
EXPECT_EQ(permission.isGroupWritable(), false);
EXPECT_EQ(permission.isGroupRunable(), false);
EXPECT_EQ(permission.isOtherReadable(), false);
EXPECT_EQ(permission.isOtherWritable(), false);
EXPECT_EQ(permission.isOtherRunable(), false);
EXPECT_EQ(permission.getRight(), "rwx------");
}
TEST(TestPermission, group) {
2018-09-13 23:16:14 +02:00
etk::path::Permissions permission(0070);
2018-08-31 21:43:16 +02:00
EXPECT_EQ(permission.isUserReadable(), false);
EXPECT_EQ(permission.isUserWritable(), false);
EXPECT_EQ(permission.isUserRunable(), false);
EXPECT_EQ(permission.isGroupReadable(), true);
EXPECT_EQ(permission.isGroupWritable(), true);
EXPECT_EQ(permission.isGroupRunable(), true);
EXPECT_EQ(permission.isOtherReadable(), false);
EXPECT_EQ(permission.isOtherWritable(), false);
EXPECT_EQ(permission.isOtherRunable(), false);
EXPECT_EQ(permission.getRight(), "---rwx---");
}
TEST(TestPermission, other) {
2018-09-13 23:16:14 +02:00
etk::path::Permissions permission(0007);
2018-08-31 21:43:16 +02:00
EXPECT_EQ(permission.isUserReadable(), false);
EXPECT_EQ(permission.isUserWritable(), false);
EXPECT_EQ(permission.isUserRunable(), false);
EXPECT_EQ(permission.isGroupReadable(), false);
EXPECT_EQ(permission.isGroupWritable(), false);
EXPECT_EQ(permission.isGroupRunable(), false);
EXPECT_EQ(permission.isOtherReadable(), true);
EXPECT_EQ(permission.isOtherWritable(), true);
EXPECT_EQ(permission.isOtherRunable(), true);
EXPECT_EQ(permission.getRight(), "------rwx");
}