问题列表 - 第26949页

我为什么要在PHP中使用测试框架?

我最近听到很多人争论使用PHP测试功能,如PHPunit和SimpleTest以及他们选择的IDE(Eclipse for me).在谷歌搜索主题后,我仍然很难理解使用这些测试框架来加速开发的利弊.

如果有人能够在更基本的层面上为我解释这一点,我会非常感激.我正在使用PHP5作为通知.

非常感谢!

php phpunit unit-testing simpletest

2
推荐指数
1
解决办法
217
查看次数

Visual Studio for F#中的代码折叠

我发现我倾向于在F#中编写长源文件.F#中的一些开源项目也有很长的源文件,例如FPersec和F#for excel.

因此,如果在VS for F#中可以使用代码折叠(甚至非常有限的支持),那将非常有用.例如,在一个模块中,我们可以折叠出稳定的函数,只留下可能发生变化的函数.

此功能是否易于支持,例如第三方供应商?

f# visual-studio

11
推荐指数
2
解决办法
1971
查看次数

无法将表单内容保存到数据库

我试图在'微博'最小应用程序中保存用户100个字符.我的代码似乎没有任何错误,但不起作用.错误是在views.py中,我无法将外键保存到用户表.

models.py 看起来像这样:

class NewManager(models.Manager):

    def create_post(self, post, username):
 new = self.model(post=post, created_by=username)
        new.save()
        return new

class New(models.Model):

    post = models.CharField(max_length=120)
    date = models.DateTimeField(auto_now_add=True)
    created_by = models.ForeignKey(User, blank=True) 
    objects = NewManager()   


class NewForm(ModelForm):

    class Meta:
          model = New
          fields = ['post']
         # widgets = {'post': Textarea(attrs={'cols': 80, 'rows': 20})

def save_new(request):

    if request.method == 'POST':
        created_by = User.objects.get(created_by = user) 
        date = request.POST.get('date', '')
        post = request.POST.get('post', '')
        new_obj = New(post=post, date=date, created_by=created_by)
        new_obj.save()
        return HttpResponseRedirect('/')
     else:
           form = NewForm() …
Run Code Online (Sandbox Code Playgroud)

forms django foreign-keys insert

5
推荐指数
1
解决办法
1980
查看次数

自定义字符串类(C++)

我正在尝试编写自己的C++ String类,用于教育和需求目的.
首先,我对操作员知之甚少,这就是我想学习它们的原因.我开始编写我的课程但是当我运行它时会阻止程序,但不会发生任何崩溃.
在进一步阅读之前,请先查看以下代码:

class CString
{
private:
  char* cstr;
public:
  CString();
  CString(char* str);
  CString(CString& str);
  ~CString();

  operator char*();
  operator const char*();
  CString operator+(const CString& q)const;
     CString operator=(const CString& q);
};
Run Code Online (Sandbox Code Playgroud)

首先,我不太确定我宣布一切正确.我尝试谷歌搜索它,但所有关于重载的教程解释了基本的ideea,这很简单,但缺乏解释如何以及何时调用每个东西.例如,在my =运算符中,程序调用CString(CString&str); 但我不知道为什么.
我还附上了下面的cpp文件:

CString::CString()
{
 cstr=0;
}
CString::CString(char *str)
{
 cstr=new char[strlen(str)];
 strcpy(cstr,str);
}
CString::CString(CString& q)
{
 if(this==&q)
  return;
 cstr = new char[strlen(q.cstr)+1];
 strcpy(cstr,q.cstr);
}
CString::~CString()
{
 if(cstr)
  delete[] cstr;
}
CString::operator char*()
{
 return cstr;
}
CString::operator const char* ()
{
 return cstr;
}
CString CString::operator +(const …
Run Code Online (Sandbox Code Playgroud)

c++ string overloading reference operator-keyword

6
推荐指数
1
解决办法
1万
查看次数

10
推荐指数
1
解决办法
9107
查看次数

PHP TTF/OTF阅读器

有没有人知道我可以传入字体文件(ttf或otf)的字体阅读器类,我可以找到字体名称,模型,艺术家等元数据真的.

谢谢大家的帮助

php

4
推荐指数
1
解决办法
1078
查看次数

是否必须在className.java中编写类className?

我正在使用maven来构建项目并且编译失败,因为我把课程Test2放入Test.java,

但它是因为maven还是因为java本身不支持这个?

顺便说一句,我怎么能用eclipse打开一个maven项目?

java syntax

4
推荐指数
2
解决办法
724
查看次数

对Haskell中的case语句的多个动作

关于晚上的最后一个问题,我正在构建我的Haskell程序的主要输入功能,我必须检查引入的args

所以我用

args <- getArgs
case length args of
    0 -> putStrLn "No Arguments, exiting"
    otherwise -> { other methods here}
Run Code Online (Sandbox Code Playgroud)

有没有一种智能的方法来设置其他方法,或者编写一个其他情况被抛到主要内部的函数是否符合我的最佳利益?

或者是否有更好的解决案件问题的方法.我只需要一个名字.

io haskell function

1
推荐指数
1
解决办法
1792
查看次数

抽象类C++中的变量

我有一个抽象类CommandPath,以及一些派生类,如下所示:

class CommandPath {
    public:
        virtual CommandResponse handleCommand(std::string) = 0;
        virtual CommandResponse execute() = 0;
        virtual ~CommandPath() {}
};

class GetTimeCommandPath : public CommandPath {
    int stage;
    public:
        GetTimeCommandPath() : stage(0) {}
        CommandResponse handleCommand(std::string);
        CommandResponse execute();
};
Run Code Online (Sandbox Code Playgroud)

所有派生类都有成员变量'stage'.我想在所有这些中构建一个函数,它以相同的方式操纵'stage',所以我没有多次定义它,而是认为我将它构建到父类中.我将'stage'从所有派生类的私有部分移动到CommandPath的受保护部分,并添加了如下函数:

class CommandPath {
    protected:
        int stage;
    public:
        virtual CommandResponse handleCommand(std::string) = 0;
        virtual CommandResponse execute() = 0;
        std::string confirmCommand(std::string, int, int, std::string, std::string);
        virtual ~CommandPath() {}
};

class GetTimeCommandPath : public CommandPath {
    public:
        GetTimeCommandPath() : stage(0) {}
        CommandResponse handleCommand(std::string);
        CommandResponse execute(); …
Run Code Online (Sandbox Code Playgroud)

c++ abstract-class

4
推荐指数
1
解决办法
9847
查看次数

配置没有任何版本信息 - 假设配置是针对1.5版的

在ccnet.config中设置版本的位置?我搜索和阅读文档,但没有提到版本.

cruisecontrol.net

12
推荐指数
1
解决办法
3338
查看次数