private

JUnit Testing private variables? [duplicate]

那年仲夏 提交于 2019-12-03 04:08:50
This question already has answers here : How do I test a private function or a class that has private methods, fields or inner classes? (51 answers) I have been assigned the task of unit testing a class that I never worked directly on with JUnit, and am strictly forbidden to change the code in the package. This is usually no issue, since most of our unit testing is just for functionality and input/output consistency, which can be done simply by running routines and checking their return values. However, occasionally there is a need to check a private variable within the class, or directly edit

Why is it legal to inappropriately access privates in an explicit instantiation?

帅比萌擦擦* 提交于 2019-12-03 02:43:22
Why on earth would this be allowed: ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// template<typename T> struct invisible { static typename T::type value; }; template<typename T> typename T::type invisible<T>::value; ////////////////////////////////////////////////////////////////////////// template<typename T, typename T::type P> class construct_invisible { construct_invisible(){ invisible<T>::value = P; } static const construct_invisible instance; }; template<typename T, typename T::type P>

How can I declare a private property within a named category?

好久不见. 提交于 2019-12-03 02:38:55
I know about the possibility of declaring private properties on a class by putting them inside an unnamed category on that class declared in the implementation ( .m ) file of that class. That's not what I want to do. I'm dealing with a named category on a class that adds some functionality to that class. For this functionality, it would help me very much to have a private property to use in my category - so the usual way of achieving this (described above) doesn't seem to work for me. Or does it? Please enlighten me! Inside your category's implementation file, declare another category and call

iOS: Using @private to hide properties from being set

半世苍凉 提交于 2019-12-03 01:52:39
I am wring a class that has a bunch of properties that I want to only use internally. Meaning I don't want to be able to have a user access them when they have created my class. Here is what I have in my .h but it still doesn't hide those from the autocomplete menu (hitting escape to see list) in XCode: @interface Lines : UIView { UIColor *lineColor; CGFloat lineWidth; @private NSMutableArray *data; NSMutableArray *computedData; CGRect originalFrame; UIBezierPath *linePath; float point; float xCount; } @property (nonatomic, retain) UIColor *lineColor; @property (nonatomic) CGFloat lineWidth;

Private class declaration [duplicate]

淺唱寂寞╮ 提交于 2019-12-02 21:26:41
Possible Duplicate: Java: Why can we define a top level class as private? Why can't we declare a private outer class? If we can have inner private class then why can't we have outer private class...? Amit Private outer class would be useless as nothing can access it. See more details: Java: Why can we define a top level class as private? To answer your question: If we can have inner private class then why can't we have outer private class...? You can, the distinction is that the inner class is at the "class" access level, whereas the "outer" class is at the "package" access level. From the

Snapchat update status bar iOS7 update

我的未来我决定 提交于 2019-12-02 21:12:37
On the latest snapchat update, when you "swipe right for messages" the status bar turns from black to white in a sort of gradient fashion. http://imgur.com/osJI20u How are they doing this without using private API's, or are they using private API's? What I've looked into: At first glance, I thought they are just doing what everyone else does, (like rdio currently does) by screen capturing the whole screen, and then modifying/animating that screenshot. But... you cant access or animate the UIImage from that screen captures method, so although you could move/crop that screenshot, you cannot

How can I embed private youtube video in my site?

家住魔仙堡 提交于 2019-12-02 20:21:53
I have to display some private Youtube videos in my blog. I cannot embed them directly. What should I use to do this. I do not think you can embed private youtube videos on your site and even if you do, they will not be able to view it because it's private. You should set your videos to "unlisted" instead of "private". That way the video does not show up on your channel or on any search results but anyone with a link to the video can see it and you can embed the video on any site. Wessam El Mahdy I didn't try this workaround yet but theoritcally it should work, you need to use YouTube API V 3

Testing private class member in C++ without friend [duplicate]

孤街浪徒 提交于 2019-12-02 19:23:43
This question already has an answer here: How do I test a private function or a class that has private methods, fields or inner classes? 51 answers Today I had a discussion with a colleague on whether to test or not to test private members or private state in the class. He almost convinced me why it makes sense. This question does not aim to duplicate already existing StackOverflow questions about the nature and reason of testing private members, like: What is wrong with making a unit test a friend of the class it is testing? Colleagues suggestion was in my opinion a bit fragile to introduce

access private members in inheritance

主宰稳场 提交于 2019-12-02 18:59:19
I have a class A, which have a field val declared as private. I want to declare a class B, that inherit from A and have an access to val. Is there a way to do it on C++? I want to do it because I need to overload some functions of A, without changing A code at all. Thanks. Quick answer: You don't. Thats what the protected key-word is for, which you want to use if you want to grant access to subclasses but no-one else. private means that no-one has access to those variables, not even subclasses. If you cannot change code in A at all, maybe there is a public / protected access method for that

Are private methods really safe?

╄→尐↘猪︶ㄣ 提交于 2019-12-02 15:41:35
In Java the private access modifier consider as safe since it is not visible outside of the class. Then outside world doesn't know about that method either. But I thought Java reflection can use to break this rule. Consider following case: public class ProtectedPrivacy{ private String getInfo(){ return "confidential"; } } Now from another class I am going to get Info: public class BreakPrivacy{ public static void main(String[] args) throws Exception { ProtectedPrivacy protectedPrivacy = new ProtectedPrivacy(); Method method = protectedPrivacy.getClass().getDeclaredMethod("getInfo", null);