-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Objective C class and interface test case (#296)
- Loading branch information
Showing
12 changed files
with
202 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diagrams: | ||
t00085_class: | ||
type: class | ||
glob: | ||
- t00085.m | ||
filter_mode: advanced | ||
include: | ||
anyof: | ||
paths: | ||
- . | ||
elements: | ||
- NSObject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
@interface It00085 : NSObject { | ||
int _defaultMember; | ||
|
||
@public | ||
NSString *_publicMember; | ||
|
||
@protected | ||
NSString *_protectedMember; | ||
|
||
@private | ||
NSString *_privateMember; | ||
} | ||
|
||
@property (class, nonatomic, assign) NSInteger sharedCounter; | ||
|
||
@property (nonatomic, strong) NSString *name; | ||
@property (nonatomic, assign) NSInteger value; | ||
|
||
+ (void)incrementSharedCounter; | ||
+ (NSInteger)currentSharedCounter; | ||
+ (instancetype)sharedInstance; | ||
|
||
- (instancetype)initWithName:(NSString *)name value:(NSInteger)value; | ||
- (void)displayDetails; | ||
- (NSInteger)addValue:(NSInteger)otherValue; | ||
- (NSInteger)multiplyValueBy:(NSInteger)multiplier andAdd:(NSInteger)addition; | ||
- (void)resetValue; | ||
|
||
- (void)performOperationWithBlock:(void (^)(NSInteger result))block; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#import "t00085.h" | ||
|
||
@implementation It00085 | ||
|
||
// Synthesize class property | ||
static NSInteger _sharedCounter = 0; | ||
|
||
+ (NSInteger)sharedCounter { | ||
return _sharedCounter; | ||
} | ||
|
||
+ (void)setSharedCounter:(NSInteger)newValue { | ||
_sharedCounter = newValue; | ||
} | ||
|
||
// Class method implementations | ||
+ (void)incrementSharedCounter { | ||
_sharedCounter++; | ||
} | ||
|
||
+ (NSInteger)currentSharedCounter { | ||
return _sharedCounter; | ||
} | ||
|
||
+ (instancetype)sharedInstance { | ||
static It00085 *sharedInstance = nil; | ||
return sharedInstance; | ||
} | ||
|
||
// Instance method implementations | ||
- (instancetype)initWithName:(NSString *)name value:(NSInteger)value { | ||
self = [super init]; | ||
if (self) { | ||
_name = name; | ||
_value = value; | ||
|
||
// Initialize members with different access scopes | ||
_publicMember = @"Public Member"; | ||
_protectedMember = @"Protected Member"; | ||
_privateMember = @"Private Member"; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)displayDetails { | ||
NSLog(@"Name: %@, Value: %ld", self.name, (long)self.value); | ||
|
||
// Accessing members with different access scopes | ||
NSLog(@"Public Member: %@", _publicMember); | ||
NSLog(@"Protected Member: %@", _protectedMember); | ||
NSLog(@"Private Member: %@", _privateMember); | ||
} | ||
|
||
- (NSInteger)addValue:(NSInteger)otherValue { | ||
return self.value + otherValue; | ||
} | ||
|
||
- (NSInteger)multiplyValueBy:(NSInteger)multiplier andAdd:(NSInteger)addition { | ||
return (self.value * multiplier) + addition; | ||
} | ||
|
||
- (void)resetValue { | ||
self.value = 0; | ||
} | ||
|
||
// Method with a block parameter | ||
- (void)performOperationWithBlock:(void (^)(NSInteger result))block { | ||
NSInteger result = self.value * 2; | ||
block(result); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* tests/t00085/test_case.h | ||
* | ||
* Copyright (c) 2021-2024 Bartek Kryza <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
TEST_CASE("t00085") | ||
{ | ||
using namespace clanguml::test; | ||
using namespace std::string_literals; | ||
|
||
auto [config, db, diagram, model] = | ||
CHECK_CLASS_MODEL("t00085", "t00085_class"); | ||
|
||
CHECK_CLASS_DIAGRAM(*config, diagram, *model, [](const auto &src) { | ||
// REQUIRE(HasTitle(src, "Basic class diagram example")); | ||
REQUIRE(IsObjCInterface(src, "NSObject")); | ||
|
||
REQUIRE(IsObjCInterface(src, "It00085")); | ||
// REQUIRE(IsBaseClass(src, "A", "B")); | ||
REQUIRE(IsField<Protected>(src, "It00085", "_defaultMember", "int")); | ||
REQUIRE(IsField<Public>(src, "It00085", "_publicMember", "NSString *")); | ||
REQUIRE(IsField<Protected>( | ||
src, "It00085", "_protectedMember", "NSString *")); | ||
REQUIRE( | ||
IsField<Private>(src, "It00085", "_privateMember", "NSString *")); | ||
|
||
REQUIRE(IsMethod<Public, Static>( | ||
src, "It00085", "currentSharedCounter", "NSInteger")); | ||
REQUIRE(IsMethod<Public>( | ||
src, "It00085", "addValue", "NSInteger", "NSInteger otherValue")); | ||
|
||
// REQUIRE(IsAssociation<Private>(src, "D", "A", "as")); | ||
|
||
// REQUIRE(HasNote(src, "A", "left", "This is class A")); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters