private

What is the best way of testing private methods with GoogleTest? [closed]

瘦欲@ 提交于 2019-11-29 20:11:08
I would like to test some private methods using GoogleTest. class Foo { private: int bar(...) } GoogleTest allows a couple of ways of doing this. OPTION 1 With FRIEND_TEST : class Foo { private: FRIEND_TEST(Foo, barReturnsZero); int bar(...); } TEST(Foo, barReturnsZero) { Foo foo; EXPECT_EQ(foo.bar(...), 0); } This implies to include "gtest/gtest.h" in the production source file. OPTION 2 Declare a test fixture as a friend to the class and define accessors in the fixture: class Foo { friend class FooTest; private: int bar(...); } class FooTest : public ::testing::Test { protected: int bar(...)

'public static final' or 'private static final' with getter?

柔情痞子 提交于 2019-11-29 19:59:03
In Java, it's taught that variables should be kept private to enable better encapsulation, but what about static constants? This: public static final int FOO = 5; Would be equivalent in result to this: private static final int FOO = 5; ... public static getFoo() { return FOO; } But which is better practice? There's one reason to not use a constant directly in your code. Assume FOO may change later on (but still stay constant), say to public static final int FOO = 10; . Shouldn't break anything as long as nobody's stupid enough to hardcode the value directly right? No. The Java compiler will

C# override public member and make it private

萝らか妹 提交于 2019-11-29 17:46:03
问题 Possible? Can you change the access of anything to anything else? 回答1: No, you can hide a public member with a private method in a subclass, but you cannot override a public member with a private one in a subclass. And, in actually, it's not just a public/private thing, this applies to narrowing the access in general. Revised : By hiding with a more restrictive access - in this case private access - you will still see the base class member from a base-class or sub-class reference, but it

C# Set probing privatePath without app.config?

房东的猫 提交于 2019-11-29 17:40:00
问题 I have a C# application, and to organize its files I have some DLL's in a folder called "Data". I want the EXE to check this folder for the DLL's just like how it checks its current directory. If I created a App.Config with this information: <?xml version="1.0" encoding="utf-8" ?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="Data" /> </assemblyBinding> </runtime> </configuration> It works without a problem. I do not want to have an

cloning error when checking out private github repo

社会主义新天地 提交于 2019-11-29 17:28:42
I get the following error while cloning a private repo on my colleagues computer: Cloning into xxx... remote: Counting objects: 7112, done. remote: Compressing objects: 100% (4870/4870), done. remote: Total 7112 (delta 2281), reused 6503 (delta 1672) Receiving objects: 100% (7112/7112), 10.88 MiB | 975 KiB/s, done. Resolving deltas: 100% (2281/2281), done. error: refs/remotes/origin/master does not point to a valid object! error: Trying to write ref refs/heads/master with nonexistant object 5f1f9967f0d76f1f5af4ebc1d1b0dd5dcbf593c5 fatal: Cannot update the ref 'HEAD'. It works fine on my own

meteor private subdirectory

我是研究僧i 提交于 2019-11-29 17:08:11
问题 I was recently made aware of meteor private subdirectories. According to the docs: "The private subdirectory is the place for any files that should be accessible to server code but not served to the client, like private data files." I am a newbie at web development in general, so my question is what is the advantage of having these files within the private subdirectory vs. just in the server subdirectory itself? Is the server subdirectory not private - e.g. I have some email templates defined

Youtube integration in iOS SDK

[亡魂溺海] 提交于 2019-11-29 17:06:41
How I can integrate Youtube with iOS? Mainly I want to play private videos without asking for login. Login should be hard coded in the app and will not ask user before playing the private video. Some YouTube videos can be played back in a MPMoviePlayerController - some cannot. When you query a video through the YouTube Data API https://developers.google.com/youtube/2.0/reference#Videos_feed you'll get back all the content types available for a particular videos, including the Flash player, 3GPP, MP4 (if available), etc. You can use these URLs to load up a MPMoviePlayerController. This is

Rails paperclip gem - Get file from private folder

孤者浪人 提交于 2019-11-29 15:34:17
问题 I'm using paperclip to upload files to my server. If I don't specify the path, paperclip saves the file to a public folder, and then I can download it by accessing <%= @user.file.url %> in the view. But if I specify the path to a non-public folder, it's not possible getting the file from the view, obviously. I would like to know some way to download the saved files in a private folder, from the web and from a ruby script. 回答1: The first thing we need to do is add a route to routes.rb for

OpenSSL won't create private keys?

℡╲_俬逩灬. 提交于 2019-11-29 14:13:00
Okay, well, this is my first time working with encryption on a project. I am using my hosting provider for SSL, but I also want to encrypt portions of the database that are sensitive. For this, I was told to use OpenSSL. I am testing it on my localhost (WAMP), and have installed OpenSSL and turned on the PHP and Apache SSL mods. Okay, so i've been following tutorials and, using several suggested methods, have been able to generate the public key and store it as a file. For some reason, I can't seem to generate the private key. I will post two versions of code that i've tried: // generate

Why declare variables private in a class? [closed]

冷暖自知 提交于 2019-11-29 13:23:09
问题 Folks I'll start by apologising as I'm sure this has been answered elsewhere - I just can't find an answer that explains it in a way I understand! I'm doing an MSc conversion course and there are some elementary basics that I'm still struggling with this, including this one - why making a variable private is better. Say I have a Java class called Person, with a print method. I could create it and define it as such: public class Person { public String name; public String telephoneNumber;