87 lines
2.9 KiB
C++
87 lines
2.9 KiB
C++
/**
|
|
* @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>
|
|
#include <etk/path/Permissions.hpp>
|
|
|
|
TEST(TestPermission, defaultContructor) {
|
|
etk::path::Permissions permission;
|
|
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) {
|
|
etk::path::Permissions permission(0777);
|
|
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) {
|
|
etk::path::Permissions permission(0700);
|
|
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) {
|
|
etk::path::Permissions permission(0070);
|
|
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) {
|
|
etk::path::Permissions permission(0007);
|
|
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");
|
|
}
|
|
|